Git Product home page Git Product logo

Comments (8)

munozfrancisco avatar munozfrancisco commented on June 1, 2024 4

I fixed it. Just I added dist/*.* where*.*means remove all files inside this folder. You can find more about it in the documentation. It's was very confused and frustrated because the documentation mark it like an option but it's my opinion is strictly needed due to it was the only way the plugin works right to me.

Also I retreive the version webpack 3.5.6

from clean-webpack-plugin.

simaodeveloper avatar simaodeveloper commented on June 1, 2024 4

Hello folks, try setup root at the options, thats works for me, because I split the plugins in another file and added it into a sub-folder:

module.exports = function({ path }) {
    
    const plugins = [
        new CleanWebpackPlugin(['dist'], {
            root: path
        }),
        new HtmlWebpackPlugin({
            template: 'src/index.html',
            inject: 'body'
        }),
        new ExtractTextPlugin({
            filename: '[name].[hash].css'
        })
    ];

    return plugins;
}

from clean-webpack-plugin.

NemoStein avatar NemoStein commented on June 1, 2024 1

I've managed to consistently reproduce the problem.
I'm using http-server to serve my dist folder.
cmd and powershell locks the directory path, so, when this plugin tries to remove the folder it fails, but doesn't generate any error.
I think a better approach is to remove the contents of the folder instead of removing the folder itself.

from clean-webpack-plugin.

johnagan avatar johnagan commented on June 1, 2024

Is this still happening?

from clean-webpack-plugin.

munozfrancisco avatar munozfrancisco commented on June 1, 2024

I am learning webpack and follow the guide about OutManagement. Definitely, this clean-webpack-plugin doesn't work the folder dist never was cleaned. Besides, it runs properly under console without errors notification.

clean-webpack-plugin 0.1.17
webpack 3.6.0

from clean-webpack-plugin.

mountHouli avatar mountHouli commented on June 1, 2024

I'm getting this same problem. In my case, the ./junk/index.html file does not get cleaned, but everything else does.

I am certain it is not getting removed (as opposed to me thinking it doesn't get removed but really it's just getting replaced upon rebuild too fast for me to notice) because I checked the created and modified time stamps.

Here's my webpack.config.js

module.exports = {
  name: 'client',
  target: 'web',
  entry: {
    clientIndex: path.join(__dirname, 'src', 'clientIndex.js')
  },
  output: {
    filename: './public/[name].bundle.js',
    path: path.join(__dirname, 'dist'),
    publicPath: '/'
  },
  module: {
    rules: [
      {
        test: /\.js(?:x?)$/, // match .js files and .jsx files
        include: [/src/],
        loader: 'babel-loader'
      }
    ]
  },
  resolve: {
    // Make the webpack resolver look for .jsx files (in addition to defaults),
    // so you can import a .jsx file without specifying the extension
    extensions: ['.js', '.json', '.jsx']
  },
  plugins: [
    new CleanWebpackPlugin(
      [
        'dist/*.*',
        'dist/public/*.*',
        'junk/index.html'
      ],
      {
        root: __dirname,
        exclude: '.gitkeep',
        verbose: true
        // set watch: true ??
      }
    ),
    new CopyWebpackPlugin([
      // The "to:" paths are relative to the "output.path:" directory
      {from: 'src/server.js', to: './server.js'},
      {from: 'src/config.js', to: './config.js'}
    ]),
    new HtmlWebpackPlugin({
      template: 'src/index.html.template',
      // The "filename" path is relative to "output.path"
      filename: '../junk/index.html'
    })
  ]
}

If I change CleanWebpackPlugin's array of paths to clean from containing 'junk/index.html' to 'junk/*.html', it works. However, I don't want to delete all .html files in that directory--just junk/index.html.

Environment / Versions:
Mac
Node 9.8.0
webpack 3.11.0
clean-webpack-plugin 0.1.19

from clean-webpack-plugin.

mountHouli avatar mountHouli commented on June 1, 2024

BTW, this is its output (notice I have verbose: true):

clean-webpack-plugin: /Users/houli/docs/gitrepos/camp-trip-client/dist/*.* has been removed.
clean-webpack-plugin: /Users/houli/docs/gitrepos/camp-trip-client/dist/public/*.* has been removed.
clean-webpack-plugin: /Users/houli/docs/gitrepos/camp-trip-client/junk/index.html has been removed.
clean-webpack-plugin: 1 file(s) excluded - .

from clean-webpack-plugin.

yi-jy avatar yi-jy commented on June 1, 2024

The current version works well!

from clean-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.