How to save a stream into multiple destinations with Gulp.js?

I was facing similar issue and wanted the gulp source to be copied to multiple locations after lint, uglify and minify tasks. I ended up resolving this as below, gulp.task(‘script’, function() { return gulp.src(jsFilesSrc) // lint command // uglify and minify commands .pipe(concat(‘all.min.js’)) .pipe(gulp.dest(‘build/js’)) // <- Destination to one location .pipe(gulp.dest(‘../../target/build/js’)) // <- Destination to … Read more

What is the difference between browserify/requirejs modules and ES6 modules [closed]

After playing around for a while I did get a better understanding of things, also thanks to @Andy for the blog by Addy Osmani. There are different module systems: AMD (RequireJS), CommonJS (Node) and the new ES6 module syntax (and the old ES5 Global system of course). However if you want to use those in … Read more

Browserify, Babel 6, Gulp – Unexpected token on spread operator

That syntax is an experimental proposed syntax for the future, it is not part of es2015 or react so you’ll need to enable it. npm install –save-dev babel-plugin-transform-object-rest-spread and add “plugins”: [“transform-object-rest-spread”] into .babelrc alongside your existing presets. Alternatively: npm install –save-dev babel-preset-stage-3 and use stage-3 in your presets to enable all stage-3 experimental functionality.

SyntaxError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’ – Gulp

Older versions of Babel came with everything out of the box. The newer version requires you install whichever plugins your setup needs. First, you’ll need to install the ES2015 preset. npm install babel-preset-es2015 –save-dev Next, you need to tell babelify to use the preset you installed. return browserify({ … }) .transform(babelify.configure({ presets: [“es2015”] })) … … Read more

browserify error /usr/bin/env: node: No such file or directory

Some linux distributions install nodejs not as “node” executable but as “nodejs”. In this case you have to manually link to “node” as many packages are programmed after the “node” binary. Something similar also occurs with “python2” not linked to “python”. In this case you can do an easy symlink. For linux distributions which install … Read more

Is it okay to use babel-node in production

For the client side code, you’re doing the correct thing. babelify it and ship it to the client. For the server side code, I would just do a regular build using babel-cli According to http://babeljs.io/docs/setup/#babel_register, babel-register is not meant for production use — The require hook is primarily recommended for simple cases. for Babel 6+ … Read more

Browserify – How to call function bundled in a file generated through browserify in browser

The key part of bundling standalone modules with Browserify is the –s option. It exposes whatever you export from your module using node’s module.exports as a global variable. The file can then be included in a <script> tag. You only need to do this if for some reason you need that global variable to be … Read more