Last active
January 10, 2017 14:50
-
-
Save Shwartz/cb6698bcc6fc61456b0e1db0e6b0166f to your computer and use it in GitHub Desktop.
gulp webpack example with flag to run different configs
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('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