javascript - webpack: commonchunksplugin with webworker and multiple chunks -


i work on legacy application that, now, have split in specific way: simplified case : have 4 modules:

//modulea.js export const modulea = ['modulea'];   //moduleb.js import {modulea} './modulea'; export const moduleb = ['moduleb'].concat(modulea);   //modulec.js import {modulea} './modulea'; import {moduleb} './moduleb'; export const modulec = ['modulec'].concat(modulea).concat(moduleb);   //webworkermodule.js import {moduleb} './moduleb'; import {modulea} './modulea';  console.log("webworker module", modulea, moduleb); 

what need have output of 5 files:

  • manifest.js contain common runtime of webpack
  • modulea.js contains code of modulea
  • moduleb.js contains code of moduleb
  • modulec.js contains code of modulec
  • webworkermodule.js contains code of module , module b , webpack runtime

i tried multiple configuration, cannot obtain want.

const path = require('path'); const webpack = require('webpack');  const config = {     entry:{         modulea:'./src/modulea.js',         moduleb:'./src/moduleb.js',         modulec:'./src/modulec.js',         webworkermodule:'./src/webworkermodule.js',     },     output: {         path: path.resolve(__dirname, 'dist'),         filename: '[name].js'     },     resolve: {         extensions: ['.js']     },     plugins: [         new webpack.optimize.commonschunkplugin({             name: 'webworkermodule',             chunks: ['webworkermodule'],             minchunks: infinity         }),         new webpack.optimize.commonschunkplugin({             name: ['modulea', 'moduleb', 'manifest'],             chunks: ['modulea', 'moduleb', 'modulec'],             minchunks: infinity         })     ] };  module.exports = config; 

the above configuration example produce correct webworkermodule.js, modulea , moduleb duplicated in every other files.

has insight ?

i found solution:

const path = require('path'); const webpack = require('webpack');  const configww = {     entry:{         webworkermodule:'./src/webworkermodule.js',     },     output: {         path: path.resolve(__dirname, 'dist'),         filename: '[name].js'     },     resolve: {         extensions: ['.js']     }, };  const configothers =  {     entry: {         modulea:'./src/modulea.js',         moduleb:'./src/moduleb.js',         modulec:'./src/modulec.js',     },     output: {         path: path.resolve(__dirname, 'dist'),         filename: '[name].js'     },     resolve: {         extensions: ['.js']     },     plugins: [         new webpack.optimize.commonschunkplugin({             names: ['moduleb', 'modulea', 'manifest'],             minchunks: infinity         })     ] };  module.exports = [configww, configothers]; 

the main point of solution didn't know possible have multiple independent configuration.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -