[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

 

posted @ 2018-01-03 21:10  Zhentiw  阅读(320)  评论(0编辑  收藏  举报