Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
820 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 Answer

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();
    }
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...