简体   繁体   English

如何在我的 vue 应用程序的 webpack 配置中排除生产构建中的文件

[英]How to exclude files in production build in the webpack config of my vue application

I try to exclude an Html-file "dev.html" from the product build.我尝试从产品构建中排除 Html 文件“dev.html”。 How do I have to configure the webpack?如何配置 webpack? I know I have to apply rules, but where?我知道我必须应用规则,但在哪里? This is my vue.config.js这是我的 vue.config.js

module.exports = {
  "transpileDependencies": [
    "vuetify"
  ],


  pages: {
    index: {
      // entry for the page
      entry: 'src/main.ts',
      // the source template
      template: process.env.NODE_ENV === 'development' ?
        'public/dev.html' :
        'public/index.html',
      // output as dist/index.html
      filename: 'index.html',
      // when using title option,
      // template title tag needs to be <title><%= htmlWebpackPlugin.options.title %></title>
      title: 'Index Page',
      // chunks to include on this page, by default includes
      // extracted common chunks and vendor chunks.
      chunks: ['chunk-vendors', 'chunk-common', 'index']
    },
  },
  configureWebpack: {
    devtool: process.env.NODE_ENV === 'development' ? 'source-map' : 'none',

  }
}

I fixed it using the remove-files-webpack-plugin ( https://www.npmjs.com/package/remove-files-webpack-plugin )我使用 remove-files-webpack-plugin ( https://www.npmjs.com/package/remove-files-webpack-plugin ) 修复了它

 plugins: [
      new RemovePlugin({
        after: {
          include: [
            './dist/dev.html'
          ],
          trash: true
        }
      })
    ],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM