Comments (8)
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.
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.
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.
Is this still happening?
from clean-webpack-plugin.
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.
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.
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.
The current version works well!
from clean-webpack-plugin.
Related Issues (20)
- Removes whole project when outputpath is root HOT 6
- Bug report or enhancement request:reassign "this.outputPath" in "handleInitial" HOT 1
- Console warn on new line
- The typings issue while upgrade to [email protected] HOT 7
- webpack 5 output path error HOT 2
- Type 'CleanWebpackPlugin' is not assignable to type '((this: Compiler, compiler: Compiler) => void) HOT 1
- upgrading from 0.1.19 to 3.0.0 doubt
- Bad type declaration in "clean-webpack-plugin.d.ts" HOT 1
- clean-webpack-plugin: options.output.path not defined. Plugin disabled... HOT 15
- Expose glob options to distinguish files and directories
- Deprecate plugin in favor `output.clean` HOT 8
- dry: true result different from real run
- v4.0.0-alpha.0 is released as `latest` HOT 5
- Does the order of clean-webpack-plugin matter? HOT 2
- Old dependency on del causes errors on Windows
- cleanAfterEveryBuildPatterns: ['*.LICENSE.txt'] doesn't seem to work HOT 2
- Excluding files & folders not working HOT 1
- Cannot read properties of undefined (reading 'emit')
- Maintenance HOT 1
- Outdated version of package "del" causes TypeScript project compile failures HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clean-webpack-plugin.