Skip to content

Instantly share code, notes, and snippets.

@Shwartz
Last active January 10, 2017 14:50
Show Gist options
  • Save Shwartz/cb6698bcc6fc61456b0e1db0e6b0166f to your computer and use it in GitHub Desktop.
Save Shwartz/cb6698bcc6fc61456b0e1db0e6b0166f to your computer and use it in GitHub Desktop.
gulp webpack example with flag to run different configs
gulp.task('webpack', function () {
console.log('TASK:WEBPACK');
/*
* run in gulp: gulp webpack --target=prod
* to create prod JS
* */
if (gutil.env.target == 'prod') {
webpackConfig.plugins = [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
];
webpackConfig.output = {
path: PATH.resolve(__dirname, 'dist/js'),
filename: 'bundle.min.js'
}
}
// run webpack
webpack(webpackConfig, function (err, stats) {
if (err) throw new gutil.PluginError('webpack', err);
gutil.log('[webpack]', stats.toString({
colors: true,
progress: true
}));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment