johnagan / clean-webpack-plugin

A webpack plugin to remove your build folder(s) before building
MIT License
1.96k stars 137 forks source link

Output.path is dist, how to delete only js folder and css folder in dist #123

Closed jiameng123 closed 5 years ago

jiameng123 commented 5 years ago

Issue description or question

Output.path is dist, how to delete only js folder and css folder in dist

Webpack Config

output: {
    path: resolvePath("../dist"),
    publicPath: customConf.publicPath,
    filename: isDev ? `[name].[hash].js` : `js/[name].[chunkhash:8].js`,
    chunkFilename: isDev ? `[name].[hash].js` : `js/[name].[chunkhash:8].js`
  },
chrisblossom commented 5 years ago

This should point you in the right direction:

new CleanWebpackPlugin({
    // patterns are relative to webpack's output.path
    //
    // See https://github.com/sindresorhus/del#patterns for pattern matching documentation
    cleanOnceBeforeBuildPatterns: ['js/**/*', 'css/**/*'],
});