1
entry: {
    page1: '~/page1',
    page2: '~/page2',
    page3: '~/page3',
    lib: ['date-fns', 'lodash'],
    vendor: ['vue', 'vuex', 'vue-router']
},

new webpack.optimize.CommonsChunkPlugin({
    name: ['vendor', 'lib'],
    filename: '[name]-[hash].bundle.js',
}),

In the above config, I want to exclude page1 from CommonsChunkPlugin, because page1 doesn't have any common modules. So in page1, I just included page1.js which throws following error.

vendor-cb4799a58e0e134e2087.bundle.js:1 Uncaught ReferenceError: webpackJsonp is not defined

please help me on this.

Boiethios
  • 38,438
  • 19
  • 134
  • 183

2 Answers2

0

try this

new webpack.optimize.CommonsChunkPlugin({
  name: ['vendor', 'lib'],
  filename: '[name]-[hash].bundle.js',
}),

u omitted the s in 'names'. hope it helps :)

Ewomazino Ukah
  • 2,286
  • 4
  • 24
  • 40
  • @HariPrakash because of the way common chunks plugin works, u have to still add the script tag linking to the 'vendor chunk' before your page1 – Ewomazino Ukah Jan 10 '18 at 09:57
0

I followed the below article and it solves my issue https://github.com/webpack/webpack.js.org/issues/1333