wpConfig.plugins.push(new webpack.optimize.CommonsChunkPlugin({ name: opts.common.name, chunks: opts.common.chunks, wpConfig.plugins.push(new webpack.optimize.ModuleConcatenationPlugin({ optimizationBailout: true })); wpConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({ sourceMap: opts.sourceMap !== false, exclude: [/\.min\.js$/, /node_modules/],
fs.readdirSync('./src/Templates').map(function (filename) { return new htmlWebPackPlugin({ template: './src/Templates/' + filename, filename: filename }); }).concat( new webPack.optimize.CommonsChunkPlugin({ names: ['vendor', 'inline'], minChunks: Infinity }) )
config .plugin('web-commons-chunk-vendor') .use(webpack.optimize.CommonsChunkPlugin, { name: 'vendor', minChunks: module => { return module.resource && /\.(js|css|es6)$/.test(module.resource) && module.resource.indexOf('node_modules') !== -1 } }) .end() .plugin('web-commons-chunk-manifest') .use(webpack.optimize.CommonsChunkPlugin, { name: 'manifest' }) .end()
function enableVendor(config, productionMode) { var reactHot = productionMode ? [] : [ 'webpack/hot/dev-server', 'webpack-hot-middleware/client' ]; config.entry.vendor = _.union(application.vendorDependencies, [ 'react', 'react-router', 'react-css-modules', 'react-bootstrap', ], reactHot); config.plugins.push(new webpack.optimize.CommonsChunkPlugin('vendor', 'js/vendor/index.js')) }
const getUglify = env => ( env === 'production' ? new webpack.optimize.UglifyJsPlugin() : () => null )
gulp.task("dist", [ "clean" ], cb => { const config = require("./webpack.config.js"); config.plugins.push( new webpack.optimize.UglifyJsPlugin({ minimize: true }) ); const compiler = webpack(config); compiler.run((err, stats) => { if (err) throw new gutil.PluginError("webpack", err); log("[webpack]", stats.toString()); }); });
const webPlugins = env => [ new webpack.optimize.OccurrenceOrderPlugin(), ...devPlugins(env), varDefinePlugin, new LoadablePlugin(), // env === 'development' ? new BundleAnalyzerPlugin() : {}, env === 'development' ? new CrudeTimingPlugin() : () => {}, HTMLWebpackPluginConfig, MiniCssExtractPluginConfig, new CopyWebpackPlugin({ patterns: [ { from: pathAlias.staticDir, to: path.join(pathAlias.buildDir, 'static'), }, ]}), ]
gulp.task("webpack:build", function(callback) { // modify some webpack config options var myConfig = Object.create(webpackConfig); myConfig.plugins = myConfig.plugins.concat( new webpack.DefinePlugin({ "process.env": { "NODE_ENV": JSON.stringify("production") } }), new webpack.optimize.DedupePlugin(), new webpack.optimize.UglifyJsPlugin() ); // run webpack webpack(myConfig, function(err, stats) { if(err) throw new gutil.PluginError("webpack:build", err); gutil.log("[webpack:build]", stats.toString({ colors: true })); callback(); }); });
function enableVendorIfNeeded(config) { if (!bundleDependenciesSeparately) { return false; } config.entry.vendor = Object.keys(packageJson.dependencies || {}); config.plugins.push(new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js')) }
wpConfig.plugins.push(new webpack.optimize.CommonsChunkPlugin({ name: opts.common.name, chunks: opts.common.chunks, wpConfig.plugins.push(new webpack.optimize.ModuleConcatenationPlugin({ optimizationBailout: true })); wpConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({ sourceMap: opts.sourceMap !== false, exclude: [/\.min\.js$/, /node_modules/],
function enableVendor(config, productionMode) { var reactHot = productionMode ? [] : [ 'webpack/hot/dev-server', 'webpack-hot-middleware/client' ]; config.entry.vendor = _.union(application.vendorDependencies, [ 'react', 'react-router', 'react-css-modules', 'react-bootstrap', ], reactHot); config.plugins.push(new webpack.optimize.CommonsChunkPlugin('vendor', 'js/vendor/index.js')) }