How to prepare release version with SystemJS and Gulp?

You will get ” Unexpected anonymous System.register call” because the references are not being loaded in the correct order. I use JSPM to properly build my angular app for production. There are 4 parts to the process. Part 1: Compile your typescript files var ts = require(“gulp-typescript”); var tsProject = ts.createProject(“./App/tsconfig.json”); gulp.task(“compile:ts”, function () { … 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

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

Is it possible to pass a flag to Gulp to have it run tasks in different ways?

Gulp doesn’t offer any kind of util for that, but you can use one of the many command args parsers. I like yargs. Should be: var argv = require(‘yargs’).argv; gulp.task(‘my-task’, function() { return gulp.src(argv.a == 1 ? options.SCSS_SOURCE : options.OTHER_SOURCE) .pipe(sass({style:’nested’})) .pipe(autoprefixer(‘last 10 version’)) .pipe(concat(‘style.css’)) .pipe(gulp.dest(options.SCSS_DEST)); }); You can also combine it with gulp-if to … 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

How to fix “ReferenceError: primordials is not defined” in Node.js

I hit the same error. I suspect you’re using Node.js 12 and Gulp.js 3. That combination does not work: Gulp.js 3 is broken on Node.js 12 #2324 A previous workaround from Jan. does not work either: After update to Node.js 11.0.0 running Gulp.js exits with ‘ReferenceError: internalBinding is not defined’ #2246 Solution: Either upgrade to … Read more