webpack-cdn-plugin icon indicating copy to clipboard operation
webpack-cdn-plugin copied to clipboard

When webpack option has externals property is array, plugin no work

Open benleilei opened this issue 5 years ago • 0 comments

When webpack option has externals property is array, plugin no work.

in my file, load echarts

import echarts from 'echarts/lib/echarts';
import 'echarts/lib/chart/line';
import 'echarts/lib/chart/bar';
......

webpack option like

{
    externals: [/^echarts([a-zA-Z0-9\/]*)/],
    plugins: [
        new WebpackCdnPlugin({
            modules: [
                { name: 'axios', var: 'axios', path: 'axios.min.js' },
                { name: 'lodash', cdn: 'lodash.js', var: '_', path: 'lodash.min.js' },
                // { name: 'echarts', var: 'echarts', paths: 'echarts.min.js' } // it not work, chunk-vendors.js still has echarts library
                ......
            ],
            prod: true,
            publicPath: '/node_modules',
            prodUrl: ......
        })
    ]
}

build app, in chunk-vendors.js still has axios and lodash library.

  1. how to config plugin to echarts in cdn, not in chunk-vendors.js file?
  2. plugin and externals property is not at same time?

benleilei avatar Nov 03 '20 06:11 benleilei