【问题标题】:how can I exclude some folders containing .vue files from being built in vuejs?如何在 vuejs 中构建一些包含 .vue 文件的文件夹?
【发布时间】:2020-06-13 14:32:22
【问题描述】:

module.exports = {
  presets: [
    '@vue/app'
  ],
  module:{
    rules: [
      {
        test: /\.vue$/,
        exclude: [
          './src/components/Homepages/number1',
          './src/components/Homepages/number2'
        ]
      }
    ]
  }
}

我试图在我的项目中有条件地仅包含“Homepages/number1”、“Homepages/number2”、“Homepages/number3”文件夹之一,并且在运行 npm run build 减小我的 dist 文件夹大小。我正在尝试这段代码,但我确信它不是正确的解决方案。我在 babel.config.js 中做这个配置。

【问题讨论】:

    标签: javascript webpack build vuejs2


    【解决方案1】:

    一种选择是使用Copy plugin

    module.exports = {
      plugins: [
        new CopyPlugin({
          patterns: [
            {
              from: path.posix.join(
                path.resolve(__dirname, "src").replace(/\\/g, "/"),
                "**/*"
              ),
              globOptions: {
                ignore: [
                  // Ignore all `txt` files
                  "**/*.txt",
                  // Ignore all files in all subdirectories
                  "**/subdir/**",
                ],
              },
            },
          ],
        }),
      ],
    };
    

    【讨论】:

      猜你喜欢
      • 2018-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-30
      • 2014-04-07
      • 1970-01-01
      • 2018-11-15
      相关资源
      最近更新 更多