Created
May 23, 2016 02:55
-
-
Save stewhouston/27cac18c64d03b14de8b39389cbaa1c5 to your computer and use it in GitHub Desktop.
Example of a bundling task for Angular 2 with gulp (so as to reduce http/xhr requests.) Works in the context of a project created through angular-cli.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('ng-bundle', function(done) { | |
process.chdir('dist'); | |
let bundleFilename = 'app.bundle.js'; | |
const Builder = require('systemjs-builder'); | |
let builder = new Builder(); | |
builder.loadConfig('system-config.js') | |
.then(function() { | |
return builder | |
.buildStatic('main.js', bundleFilename, { | |
normalize: true, | |
minify: true, | |
mangle: true, | |
runtime: false | |
}); | |
}) | |
.then(function() { | |
console.log(`Bundle complete. \`stat ./dist/${bundleFilename}\``); | |
done(); | |
}) | |
.catch(function (err) { | |
console.log('error', err); | |
console.log('ng-bundle failed.'); | |
process.exit(1); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment