tmaximini / generator-ionic-gulp

A Yeoman generator for fast hybrid app development that stays out of your way
134 stars 36 forks source link

ES6 Support? #42

Closed mattrothenberg closed 7 years ago

mattrothenberg commented 7 years ago

First and foremost, thanks so much for creating this generator. It greatly improved my Ionic development workflow!

I wanted to pick your brain about the best way to add support for ES6. I'm using Parse as my backend, and need to leverage some ES6 features accordingly.

Any recommendations? I came across the following blog post, which seemed like it would fit nicely into the Gulp workflow that you've created!

https://labs.encoded.io/2015/06/22/use-es6-with-ionic/

mattrothenberg commented 7 years ago

And I might have spoken too soon.

I added both babelify and babel-preset-es2015, and edited the browserify() function call as so:

var b = browserify({
    entries: './app/src/app.js',
    debug: !build
  }).transform('babelify', {presets: ['es2015']});

Seems to work!

tmaximini commented 7 years ago

I might look into this when I find the time, but as I am currently not actively working on any ionic projects I don't spend much time developing this further. But I think ES6 support should be a top priority! Did you choose the browserify version and just added this stuff? I'd also happily accept a pull request :)

mattrothenberg commented 7 years ago

More than happy to submit a PR, though I've never created an Yeoman generator so I'm not quite sure what changes I would have to make.

All I did on my end were the following:

  1. npm install --save-dev babelify babel-preset-2015
  2. Modify the gulpfile by adding the aforementioned transform call to the browserify task.
var b = browserify({
  entries: './app/src/app.js',
  debug: !build
}).transform('babelify', {presets: ['es2015']});
tmaximini commented 7 years ago

most of what the generator does is just copying over a couple of files. here are the template files that are used: https://github.com/tmaximini/generator-ionic-gulp/tree/master/app/templates if I am not mistaken you'll have to change _gulpfile.browserify.js and _gulpfile.gulpfile.js with your changes. Just fork the repo and push your changes into a feature branch. You can test it locally on your machine with using npm link inside your project folder, that will replace your locally installed generator with the version you work on. If any questions come up I am happy to help.