After vue-cli references elementUI packed file is too large

Solution: Use externals reference to third-party resources, to prevent the element resources are packed into their own project, (a total of three modified pages index.html, webpack.base.conf.js, main.js)

1, modified index.html page, and then introduced into the head cdn.

 

2. Modify webpack.base.conf.js file. Adding externals Configuration

externals: { 
    views: 'View' , 
    item: 'ElementUI' , 
  },

 

3. Delete the corresponding import from main.js in. Because if not removed, will be packed when playing these two files in it

 

 

Because the project is back bigger and bigger, we found elementUI packaged together too, wanted to introduce elementUI to CDN way, but I will only use the CDN elementUI introduction will be reported can not find ElementUI,

Tried a lot of time, and saw that the elementUI of CDN usage, but also need vue CDN is introduced, otherwise always being given, can not find the element;

 

Guess you like

Origin www.cnblogs.com/wangtaolearning/p/11234645.html