【问题标题】:How to exclude files in production build in the webpack config of my vue application如何在我的 vue 应用程序的 webpack 配置中排除生产构建中的文件
【发布时间】:2020-08-22 12:16:24
【问题描述】:

我尝试从产品构建中排除 Html 文件“dev.html”。我必须如何配置 webpack? 我知道我必须应用规则,但在哪里?这是我的 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',

  }
}

【问题讨论】:

    标签: javascript vue.js web webpack webpack-4


    【解决方案1】:

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

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

    【讨论】:

    • 我正在尝试删除目录,但它给了我错误:EISDIR:对目录的非法操作,copyfile。关于如何解决这个问题的任何想法?
    猜你喜欢
    • 2021-01-06
    • 2019-04-04
    • 2019-10-02
    • 1970-01-01
    • 2023-01-02
    • 2019-01-07
    • 2022-01-22
    • 2021-12-31
    • 1970-01-01
    相关资源
    最近更新 更多