Thursday, 27 April 2017

How to create a commons chunk file from two packages?

I have two private packages with their own package.json, dependencies etc.

I have installed both into a third package with the idea I could then use webpack to build them and a commons chunk file, however it doesn't appear to want to play ball.

npm install /my/local/package1
npm install /my/local/package2

(in reality, I'd use a private npm or git)

in webpack.config.json

module.exports = {
  entry: {
    'package1': 'package1',
    'package2': 'package2'
  }
  ...,
  plugins = [
    new webpack.optimize.CommonsChunkPlugin({
      name: "commons",
    }),
    ...

When it builds, I get both packages built fine but only a minimal commons file.

I'm testing it with two packages that are identical aside from name, so should have everything in common.

Is there a way to get this done?

Or other strategy to allow me to develop separate apps, that can then be exported together with a commons chunk..



via Guy Bowden

No comments:

Post a Comment