Problems with defining paths for multiple bundles via webpack-dev-server -
i'm trying create multiple (but similiar) react apps 1 webpack config. let's directory structure:
├── src │ ├── app01 │ │ └── app01.js │ ├── app02 │ │ └── app02.js │ └── shared-components │ ├── logo │ │ ├── logo.js │ ├── nav │ │ ├── nav.js ├── dist │ ├── app01 │ │ ├── app01.html │ ├── app02 │ │ └── app02.html
in webpack.config.js have this:
var config = { //cut brevity }, devserver: { contentbase: './dist/', colors: true, inline: true } } var app1 = object.assign({}, config, { name: 'app1', entry: './src/app1/app1', output: { path: './dist/app1', publicpath: '/app1/', filename: 'bundle1.js' } }) var app2 = object.assign({}, config, { name: 'app2', entry: './src/app2/app2', output: { path: './dist/app2', publicpath: '/app2/', filename: 'bundle2.js' } }) if (process.env.node_env === 'production') { config.devtool = false config.plugins = [ new webpack.optimize.occurenceorderplugin(), new webpack.optimize.uglifyjsplugin({comments: false}), new webpack.defineplugin({ 'process.env': {node_env: json.stringify('production')} }) ] } module.exports = [app1, app2]
when run build script, webpack works , creates relevant js files in relevant folders. so: bundle1.js
in dist/app1
directory , bundle2.js
in dist/app2
directory. have problems webpack-dev-server. when run webpack-dev-server serves both bundle1.js
, bundle2.js
dist/app1
. if remove output.publicpath
properties app1
, app2
objects webpack-dev-server serves bundle1.js
, bundle2.js
dist
directory.
how should edit webpack config tell webpack-dev-server serve relevant bundles in relevant directories?
Comments
Post a Comment