[Poi] Build and Analyze Your JavaScript Bundles with Poi

Ever wonder where those extra KB in your bundle are coming from? This lesson walks you through running Poi's build process. Then we'll add a bundle analyzer to find where you may be able to trim down on your file size.

Install:

npm i -D webpack-bundle-analyzer

Build project:

poi build

poi.config.js:

const BundleAnalyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = (options) => ({
    webpack(config) {
       

        if(options.analyze) {
             config.plugins.push(
                new BundleAnalyzer()
             )
         }


        return config;
    }       
})

Run with analyzer:

poi build --analyze
原文地址:https://www.cnblogs.com/Answer1215/p/8185711.html