Webpack Exclude a specific file

后端 未结 2 1968
一整个雨季
一整个雨季 2020-11-30 10:54

I have this code In my webpack.config.prod.js and I was wondering how do I exclude all json except one in a specific path like src/configs/configs<

2条回答
  •  暖寄归人
    2020-11-30 11:36

    To make exclude work I had to escape the dot in the specific file I wanted to exclude. Here's an example of excluding favicon.ico from a general rule and adding a special rule for it:

      {
        test: /\.(ico|jpg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
        exclude: /favicon\.ico$/,
        loader: 'file-loader',
        options: {
          name: 'static/media/[name].[hash:8].[ext]',
        },
      },
      // A special rule for favicon.ico to place it into build root directory.
      {
        test: /favicon\.ico$/,
        loader: 'file-loader',
        options: {
          name: '[name].[ext]?[hash:8]',
        },
      },
    

提交回复
热议问题