Delete or not create a file for each entry in webpack

前端 未结 3 1852
时光说笑
时光说笑 2020-12-31 19:11

Hi I have a webpack config with these entry points:

  entry: {
    \'polyfills\': \'./src/polyfills.ts\',
    \'vendor\':    \'./src/vendor.ts\',
    \'app         


        
3条回答
  •  余生分开走
    2020-12-31 19:33

    I put together a webpack plugin to remove extra files based on their output size, rather than basing it on their name - it's been a little more future proof for me as I continue to add extra entry points to my webpack config.

    Install using npm or yarn

    npm install webpack-extraneous-file-cleanup-plugin --save-dev
    yarn add webpack-extraneous-file-cleanup-plugin --dev
    

    In your webpack.config.js file:

    const ExtraneousFileCleanupPlugin = require('webpack-extraneous-file-cleanup-plugin');
    
    module.exports = {
      ...
      plugins: [
        new ExtraneousFileCleanupPlugin({
          extensions: ['.js']
        })
      ]
    }
    

    You can see the full list of options on the Webpack Extraneous File Cleanup Plugin Github Page

提交回复
热议问题