johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cleanAfterEveryBuildPatterns: ['*.LICENSE.txt'] doesn't seem to work

Jun711 opened this issue · comments

commented

Issue description or question

I tried to use cleanAfterEveryBuildPatterns: ['*.LICENSE.txt'] to remove LICENSE.txt files. According to this comment, the person was able to remove the LICENSE.txt files. However, it doesn't seem to work for me.

Webpack Config

A minimal repo: https://github.com/Jun711/clean-webpack-test

// paste your webpack config here
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
  mode: 'production',
  entry: [
    './src/test.js',
  ],
  module: {
    rules: [
      {
        test: /\.m?js/,
        resolve: {
            fullySpecified: false
        }
      },
      {
        test: /\.(js)$/,
        exclude: /node_modules/,
        use: ['babel-loader']
      }
    ]
  },
  resolve: {
    extensions: ['*', '.js']
  },
  plugins: [
    new CleanWebpackPlugin({
      cleanAfterEveryBuildPatterns: ['*.LICENSE.txt'],
    })
  ],
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
  }
}

Environment

Run: npx envinfo --system --binaries --npmPackages clean-webpack-plugin,webpack

# Paste the result here
 System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
    Memory: 529.24 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.16.3 - ~/.nvm/versions/node/v12.16.3/bin/node
    Yarn: 1.19.2 - ~/.yarn/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v12.16.3/bin/npm
  npmPackages:
    clean-webpack-plugin: ^4.0.0-alpha.0 => 4.0.0-alpha.0 
    webpack: ^5.48.0 => 5.49.0 

you should add protectWebpackAssets: false

 plugins: [
    new CleanWebpackPlugin({
      protectWebpackAssets: false,
      cleanAfterEveryBuildPatterns: ['*.LICENSE.txt'],
    })
  ],
commented

you should add protectWebpackAssets: false

 plugins: [
    new CleanWebpackPlugin({
      protectWebpackAssets: false,
      cleanAfterEveryBuildPatterns: ['*.LICENSE.txt'],
    })
  ],

I see. Thanks.