javascript - Generate two webpack packages with slightly different configs at once -
i'm trying generate twice amount of packages/chunks in webpack difference 1 loads includepaths
of ie9 styles , other doesn't, , lazy load 1 package or other depending on browser. i've got lazy loading part down i'm not sure how generate bundles. here's standard config relevant parts being scss
loader , apppaths
variable set @ top:
var fs = require('fs'), path = require('path'), webpack = require('webpack'), apps = fs.readdirsync('./app'); appmoduleregex = new regexp("^(" + apps.join('|') + ")/(.*)$"), apppaths = apps.map(function(appname) { return 'app/' + appname + '/src'; }); entrypoints = {}; apps.foreach(function(appname) { entrypoints[appname] = [ 'webpack/hot/dev-server', appname + '/app' ] }); entrypoints['vendor'] = [ 'classnames', 'd3', 'fetch', 'lodash', 'moment', 'react', 'react-router', 'react-select', 'zxcvbn2', ]; module.exports = { entry: entrypoints, output: { path: '/web/dist', filename: '[name].bundle.js' }, module: { loaders: [ { test: /\.js$/, exclude: /\.test.js$|node_modules/, loader: 'babel-loader' }, { test: /\.json$/, loader: 'json-loader' }, { test: /\.css$/, loader: 'style-loader!css-loader!autoprefixer-loader?{browsers:["last 2 versions","ie >= 9"]}' }, { test: /\.scss$/, loader: 'style!css!autoprefixer-loader?{browsers:["last 2 versions","ie >= 9"]}!sass?includepaths[]=' + apppaths.join(',') }, { test: /\.svg$/, exclude: /\.file\.svg$/i, loader: 'raw-loader' }, { test: /\.file\.svg$|\.(jpe?g|png|gif)$/i, loaders: [ 'file?hash=sha512&digest=hex&name=[hash].[ext]', 'image-webpack?bypassondebug&optimizationlevel=7&interlaced=false' ] } ] }, resolveloader: { root: path.join(process.cwd(), "node_modules") }, resolve: { modulesdirectories: ['node_modules', 'bower_components'], alias: { 'fetch': '/web/node_modules/whatwg-fetch/fetch' } }, plugins: [ new webpack.optimize.commonschunkplugin("vendor", "vendor.bundle.js"), new webpack.normalmodulereplacementplugin(appmoduleregex, function(result) { result.request = result.request.replace(appmoduleregex, "/web/app/$1/src/$2"); }), new webpack.hotmodulereplacementplugin() ], devserver: { contentbase: '/web/dist/', host: '0.0.0.0', watchoptions: { aggregatetimeout: 500, poll: 500 }, stats: {colors: true} } }
and change want make here @ top:
apppaths = apps.map(function(appname) { // change ie9-styles return 'app/' + appname + '/src/ie9-styles'; });
which can see changes scss loader in different directory load ie9 styles correctly. how can generate these packages @ once instead of 1 or other?
Comments
Post a Comment