webpack - CommonsChunkPlugin doesn't work with electron -
i have electron app i'm building webpack 2. have custom module (mymodule
) want separate bundle referenced other bundles. problem when use commonschunkplugin
main process, electron locks app starting. can see electron logo appear in doc window never shows up.
note doesn't have module wrote, can use lodash
commonschunkplugin
, same result.
interestingly, if use commonschunksplugin
renderer process in same way, works fine.
i put simple electron app shows issue.
the github repo gives more details on situation, here important parts:
electron main process:
const mymod = require('./mymodule') app.on('ready', function() { console.log(mymod.abc); mainwindow = new browserwindow({width: 800, height: 600}); mainwindow.loadurl(url.format({ pathname: require('./index.html') })); });
webpack config main:
entry: { main: path.join(__dirname, './main.js'), mymod: ['./mymodule'] }, output: { path: __dirname + '/build/', publicpath: __dirname + '/build/', filename: '[name].bundle.js' }, plugins: [ new webpack.optimize.commonschunkplugin('mymod') ]
in state, app not work. if go webpack.main.js
file , comment out use of commonschunkplugin
in these lines start working:
entry: { main: path.join(__dirname, './main.js'), // mymod: ['./mymodule'] }, output: { path: __dirname + '/build/', publicpath: __dirname + '/build/', filename: '[name].bundle.js' }, plugins: [ // new webpack.optimize.commonschunkplugin('mymod') ]
here environment info:
macos: 10.12.6 node: v6.11.0 npm: 3.10.10 electron: v1.6.12 wepback2: 3.5.5
so what's going on here? bug electron, webpack, or code?
Comments
Post a Comment