Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
824 views
in Technique[技术] by (71.8m points)

xlsx - Removing unused heavy packages from vue.js

So recently I have been really wanting to speed up my website that is kinda heavy but when I built the app I noticed that I have 2 packages that are really heavy and I'm not using or at least I don't know whats using them.

The packages are pdmake.js and xlsx.js as you can see in the picture below: enter image description here

I tried to uninstall them but it didn't work I also checked package.json and they aren't there so I'm really confused about these 2 specific packages. I also don't have any of these files in my js folder or any folder in my project.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

pdfmake.js and xlsx.js are included by AmCharts

They are fetched by browsers dynamically and only when needed - so the only downside is increased build time. If you are sure you do not need/use these - you can disable them through vue.config.js:

// vue.config.js
module.exports = {
  chainWebpack: config => 
  {
    config.externals = function (context, request, callback) 
    {
      if (/xlsx|canvg|pdfmake/.test(request)) 
      {
        return callback(null, "commonjs " + request);
      }
      callback();
    }
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...