Closed sahismailakpolat closed 5 years ago
Change your config to:
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['**/*', '!.gitignore'],
})
Please read the readme and https://github.com/johnagan/clean-webpack-plugin/issues/106.
const path = require("path");
const webpackMerge = require("webpack-merge");
const autoprefixer = require("autoprefixer");
const webpackCommon = require("./common.config");
// webpack plugins
const HtmlWebpackPlugin = require("html-webpack-plugin");
const DefinePlugin = require("webpack/lib/DefinePlugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
module.exports = webpackMerge(webpackCommon, {
bail: true,
devtool: "source-map",
mode: "production",
output: {
path: path.resolve(__dirname, "../dist"),
filename: "[name]-[hash].min.js",
sourceMapFilename: "[name]-[hash].map",
chunkFilename: "[id]-[chunkhash].js",
publicPath: "/"
},
module: {
rules: [
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: {
sourceMap: true,
importLoaders: 2
}
},
{
loader: "postcss-loader",
options: {
config: {
path: path.resolve(__dirname, "postcss.config.js")
},
sourceMap: true
}
},
{
loader: "sass-loader",
options: {
outputStyle: "expanded",
sourceMap: true,
sourceMapContents: true
}
}
]
})
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, "../static/index.html"),
favicon: path.resolve(__dirname, "../static/favicon.ico"),
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
}),
new CopyWebpackPlugin([{ from: path.resolve(__dirname, "../static") }], {
ignore: ["index.html", "favicon.ico"]
}),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['**/*', '!.gitignore'],
}),
new DefinePlugin({
"process.env": {
NODE_ENV: '"production"'
}
}),
new ExtractTextPlugin("[name]-[chunkhash].min.css"),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
ie8: true,
warnings: false
},
mangle: {
ie8: true
},
output: {
comments: false,
ie8: true
}
},
sourceMap: true
}),
new LoaderOptionsPlugin({
options: {
context: "/",
sassLoader: {
includePaths: [path.resolve(__dirname, "../src")]
}
}
})
]
});
I changed to config to new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: ['**/*', '!.gitignore'], })
still receiving same error
Change your config to:
new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: ['**/*', '!.gitignore'], })
Please read the readme and #106.
Change your config to:
new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: ['**/*', '!.gitignore'], })
Please read the readme and #106.
I changed to config to new CleanWebpackPlugin({ cleanOnceBeforeBuildPatterns: ['**/*', '!.gitignore'], })
still receiving same error
Please paste the results of the following command:
npx envinfo --system --binaries --npmPackages clean-webpack-plugin,webpack
I suspect you are getting a different error now and you need up update your require statement to:
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
Please paste the results of the following command:
npx envinfo --system --binaries --npmPackages clean-webpack-plugin,webpack
const path = require("path");
const webpackMerge = require("webpack-merge");
const autoprefixer = require("autoprefixer");
const webpackCommon = require("./common.config");
// webpack plugins
const HtmlWebpackPlugin = require("html-webpack-plugin");
const DefinePlugin = require("webpack/lib/DefinePlugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
module.exports = webpackMerge(webpackCommon, {
bail: true,
devtool: "source-map",
mode: "production",
output: {
path: path.resolve(__dirname, "../dist"),
filename: "[name]-[hash].min.js",
sourceMapFilename: "[name]-[hash].map",
chunkFilename: "[id]-[chunkhash].js",
publicPath: "/"
},
module: {
rules: [
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: {
sourceMap: true,
importLoaders: 2
}
},
{
loader: "postcss-loader",
options: {
config: {
path: path.resolve(__dirname, "postcss.config.js")
},
sourceMap: true
}
},
{
loader: "sass-loader",
options: {
outputStyle: "expanded",
sourceMap: true,
sourceMapContents: true
}
}
]
})
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, "../static/index.html"),
favicon: path.resolve(__dirname, "../static/favicon.ico"),
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
}),
new CopyWebpackPlugin([{ from: path.resolve(__dirname, "../static") }], {
ignore: ["index.html", "favicon.ico"]
}),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ["**/*", "!.gitignore"]
}),
new DefinePlugin({
"process.env": {
NODE_ENV: '"production"'
}
}),
new ExtractTextPlugin("[name]-[chunkhash].min.css"),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
ie8: true,
warnings: false
},
mangle: {
ie8: true
},
output: {
comments: false,
ie8: true
}
},
sourceMap: true
}),
new LoaderOptionsPlugin({
options: {
context: "/",
sassLoader: {
includePaths: [path.resolve(__dirname, "../src")]
}
}
})
]
});
Please paste the results of the following command:
npx envinfo --system --binaries --npmPackages clean-webpack-plugin,webpack
This does not show your version of clean-webpack-plugin
or webpack
. Please include that.
Can you provide an example repository?
"clean-webpack-plugin": "^0.1.19", "webpack": "^4.35.0"
Your version listed is very old. Please update your version of clean-webpack-plugin
to ^3.0.0
and post if you are still having issues. I suspect you are also having a weird dependency lock file issue, so you should also try removing your lock files and starting from there.
const path = require("path");
const webpackMerge = require("webpack-merge");
const autoprefixer = require("autoprefixer");
const webpackCommon = require("./common.config");
// webpack plugins
const HtmlWebpackPlugin = require("html-webpack-plugin");
const DefinePlugin = require("webpack/lib/DefinePlugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin");
module.exports = webpackMerge(webpackCommon, {
bail: true,
devtool: "source-map",
mode: "production",
output: {
path: path.resolve(__dirname, "../dist"),
filename: "[name]-[hash].min.js",
sourceMapFilename: "[name]-[hash].map",
chunkFilename: "[id]-[chunkhash].js",
publicPath: "/"
},
module: {
rules: [
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: {
sourceMap: true,
importLoaders: 2
}
},
{
loader: "postcss-loader",
options: {
config: {
path: path.resolve(__dirname, "postcss.config.js")
},
sourceMap: true
}
},
{
loader: "sass-loader",
options: {
outputStyle: "expanded",
sourceMap: true,
sourceMapContents: true
}
}
]
})
}
]
},
plugins: [
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, "../static/index.html"),
favicon: path.resolve(__dirname, "../static/favicon.ico"),
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
}),
new CopyWebpackPlugin([{ from: path.resolve(__dirname, "../static") }], {
ignore: ["index.html", "favicon.ico"]
}),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ["**/*", "!.gitignore"]
}),
new DefinePlugin({
"process.env": {
NODE_ENV: '"production"'
}
}),
new ExtractTextPlugin("[name]-[chunkhash].min.css"),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
ie8: true,
warnings: false
},
mangle: {
ie8: true
},
output: {
comments: false,
ie8: true
}
},
sourceMap: true
}),
new LoaderOptionsPlugin({
options: {
context: "/",
sassLoader: {
includePaths: [path.resolve(__dirname, "../src")]
}
}
})
]
})
Could you share the repository with me / create a minimal reproducible example? You clearly have a plain object. Here is the check object code: src/clean-webpack-plugin.ts#L67-L75
@sahismailakpolat is there an update on this?
Closing this. If this is still an issue, please reopen with requested information.