Concat scripts in order with Gulp

I had a similar problem recently with Grunt when building my AngularJS app. Here’s a question I posted. What I ended up doing is to explicitly list the files in order in the grunt config. The config file will then look like this: [ ‘/path/to/app.js’, ‘/path/to/mymodule/mymodule.js’, ‘/path/to/mymodule/mymodule/*.js’ ] Grunt is able to figure out which … Read more

How to prevent moment.js from loading locales with webpack?

The code require(‘./locale/’ + name) can use every file in the locale dir. So webpack includes every file as module in your bundle. It cannot know which language you are using. There are two plugins that are useful to give webpack more information about which module should be included in your bundle: ContextReplacementPlugin and IgnorePlugin. … Read more

Pass Parameter to Gulp Task

It’s a feature programs cannot stay without. You can try yargs. npm install –save-dev yargs You can use it like this: gulp mytask –production –test 1234 In the code, for example: var argv = require(‘yargs’).argv; var isProduction = (argv.production === undefined) ? false : true; For your understanding: > gulp watch console.log(argv.production === undefined); <– … Read more

Excluding files/directories from Gulp task

Quick answer On src, you can always specify files to ignore using “!”. Example (you want to exclude all *.min.js files on your js folder and subfolder: gulp.src([‘js/**/*.js’, ‘!js/**/*.min.js’]) You can do it as well for individual files. Expanded answer: Extracted from gulp documentation: gulp.src(globs[, options]) Emits files matching provided glob or an array of … Read more

After installation of Gulp: “no command ‘gulp’ found”

That’s perfectly normal. If you want gulp-cli available on the command line, you need to install it globally. npm install –global gulp-cli See the install instruction. Also, node_modules/.bin/ isn’t in your $PATH. But it is automatically added by npm when running npm scripts (see this blog post for reference). So you could add scripts to … Read more

Expected linebreaks to be ‘LF’ but found ‘CRLF’ linebreak-style

Check if you have the linebreak-style rule configure as below either in your .eslintrc or in source code: /*eslint linebreak-style: [“error”, “unix”]*/ Since you’re working on Windows, you may want to use this rule instead: /*eslint linebreak-style: [“error”, “windows”]*/ Refer to the documentation of linebreak-style: When developing with a lot of people all having different … Read more

Gulp error: The following tasks did not complete: Did you forget to signal async completion?

Since your task might contain asynchronous code you have to signal gulp when your task has finished executing (= “async completion”). In Gulp 3.x you could get away without doing this. If you didn’t explicitly signal async completion gulp would just assume that your task is synchronous and that it is finished as soon as … Read more