Skip to content

Commit 5429553

Browse files
committed
feature #760 upgrading to clean-webpack-plugin 3.0 (weaverryan)
This PR was merged into the master branch. Discussion ---------- upgrading to clean-webpack-plugin 3.0 Closes #751 Commits ------- d697be8 upgrading to clean-webpack-plugin 3.0
2 parents 2eaa4ad + d697be8 commit 5429553

File tree

6 files changed

+69
-19
lines changed

6 files changed

+69
-19
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## 0.30.0
44

5+
* Upgraded `clean-webpack-plugin` from `^0.1.19` to `^3.0.0`. You
6+
should not notice significant changes unless you use
7+
`Encore.cleanupOutputBeforeBuild()` and pass custom options.
8+
For more info, see [v1 to v2 upgrade notes](https://github.com/johnagan/clean-webpack-plugin/issues/106)
9+
and [v2 to v3 upgrade notes](https://github.com/johnagan/clean-webpack-plugin/releases/tag/v3.0.0).
10+
There were no changes from `0.1.19` to `1.0.0`.
11+
512
* The `fork-ts-checker-webpack-plugin` package was upgraded for the tests
613
from `^0.4.1` to `^4.0.0`. If you're using `enableForkedTypeScriptTypesChecking()`,
714
you control the `fork-ts-checker-webpack-plugin` version in your

lib/plugins/clean.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
const WebpackConfig = require('../WebpackConfig'); //eslint-disable-line no-unused-vars
13-
const CleanWebpackPlugin = require('clean-webpack-plugin');
13+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
1414
const PluginPriorities = require('./plugin-priorities');
1515
const applyOptionsCallback = require('../utils/apply-options-callback');
1616

@@ -28,13 +28,12 @@ module.exports = function(plugins, webpackConfig) {
2828
}
2929

3030
const cleanWebpackPluginOptions = {
31-
root: webpackConfig.outputPath,
3231
verbose: false,
32+
cleanOnceBeforeBuildPatterns: webpackConfig.cleanWebpackPluginPaths
3333
};
3434

3535
plugins.push({
3636
plugin: new CleanWebpackPlugin(
37-
webpackConfig.cleanWebpackPluginPaths,
3837
applyOptionsCallback(webpackConfig.cleanWebpackPluginOptionsCallback, cleanWebpackPluginOptions)
3938
),
4039
priority: PluginPriorities.CleanWebpackPlugin

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"assets-webpack-plugin": "^3.9.7",
3232
"babel-loader": "^8.0.0",
3333
"chalk": "^4.0.0",
34-
"clean-webpack-plugin": "^0.1.19",
34+
"clean-webpack-plugin": "^3.0.0",
3535
"css-loader": "^3.5.2",
3636
"fast-levenshtein": "^2.0.6",
3737
"file-loader": "^6.0.0",

test/config-generator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const RuntimeConfig = require('../lib/config/RuntimeConfig');
1515
const configGenerator = require('../lib/config-generator');
1616
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1717
const ManifestPlugin = require('webpack-manifest-plugin');
18-
const CleanWebpackPlugin = require('clean-webpack-plugin');
18+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
1919
const webpack = require('webpack');
2020
const path = require('path');
2121
const logger = require('../lib/logger');

test/plugins/clean.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
const expect = require('chai').expect;
13-
const CleanWebpackPlugin = require('clean-webpack-plugin');
13+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
1414
const WebpackConfig = require('../../lib/WebpackConfig');
1515
const RuntimeConfig = require('../../lib/config/RuntimeConfig');
1616
const cleanPluginUtil = require('../../lib/plugins/clean');
@@ -41,8 +41,8 @@ describe('plugins/clean', () => {
4141
cleanPluginUtil(plugins, config);
4242
expect(plugins.length).to.equal(1);
4343
expect(plugins[0].plugin).to.be.instanceof(CleanWebpackPlugin);
44-
expect(plugins[0].plugin.paths).to.deep.equal(['**/*']);
45-
expect(plugins[0].plugin.options.dry).to.equal(false);
44+
expect(plugins[0].plugin.cleanOnceBeforeBuildPatterns).to.deep.equal(['**/*']);
45+
expect(plugins[0].plugin.dry).to.equal(false);
4646
});
4747

4848
it('enabled with custom paths and options callback', () => {
@@ -56,8 +56,8 @@ describe('plugins/clean', () => {
5656
cleanPluginUtil(plugins, config);
5757
expect(plugins.length).to.equal(1);
5858
expect(plugins[0].plugin).to.be.instanceof(CleanWebpackPlugin);
59-
expect(plugins[0].plugin.paths).to.deep.equal(['**/*.js', '**/*.css']);
60-
expect(plugins[0].plugin.options.dry).to.equal(true);
59+
expect(plugins[0].plugin.cleanOnceBeforeBuildPatterns).to.deep.equal(['**/*.js', '**/*.css']);
60+
expect(plugins[0].plugin.dry).to.equal(true);
6161
});
6262

6363
it('enabled with an options callback that returns an object', () => {
@@ -68,13 +68,13 @@ describe('plugins/clean', () => {
6868
options.dry = true;
6969

7070
// This should override the original config
71-
return { foo: true };
71+
return { verbose: true };
7272
});
7373

7474
cleanPluginUtil(plugins, config);
7575
expect(plugins.length).to.equal(1);
7676
expect(plugins[0].plugin).to.be.instanceof(CleanWebpackPlugin);
77-
expect(plugins[0].plugin.options.dry).to.equal(false);
78-
expect(plugins[0].plugin.options.foo).to.equal(true);
77+
expect(plugins[0].plugin.dry).to.equal(false);
78+
expect(plugins[0].plugin.verbose).to.equal(true);
7979
});
8080
});

yarn.lock

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,11 @@
865865
lodash "^4.17.13"
866866
to-fast-properties "^2.0.0"
867867

868+
"@types/anymatch@*":
869+
version "1.3.1"
870+
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
871+
integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==
872+
868873
"@types/color-name@^1.1.1":
869874
version "1.1.1"
870875
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
@@ -899,6 +904,44 @@
899904
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8"
900905
integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==
901906

907+
"@types/source-list-map@*":
908+
version "0.1.2"
909+
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
910+
integrity sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==
911+
912+
"@types/tapable@*":
913+
version "1.0.5"
914+
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.5.tgz#9adbc12950582aa65ead76bffdf39fe0c27a3c02"
915+
integrity sha512-/gG2M/Imw7cQFp8PGvz/SwocNrmKFjFsm5Pb8HdbHkZ1K8pmuPzOX4VeVoiEecFCVf4CsN1r3/BRvx+6sNqwtQ==
916+
917+
"@types/uglify-js@*":
918+
version "3.9.0"
919+
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.9.0.tgz#4490a140ca82aa855ad68093829e7fd6ae94ea87"
920+
integrity sha512-3ZcoyPYHVOCcLpnfZwD47KFLr8W/mpUcgjpf1M4Q78TMJIw7KMAHSjiCLJp1z3ZrBR9pTLbe191O0TldFK5zcw==
921+
dependencies:
922+
source-map "^0.6.1"
923+
924+
"@types/webpack-sources@*":
925+
version "0.1.7"
926+
resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-0.1.7.tgz#0a330a9456113410c74a5d64180af0cbca007141"
927+
integrity sha512-XyaHrJILjK1VHVC4aVlKsdNN5KBTwufMb43cQs+flGxtPAf/1Qwl8+Q0tp5BwEGaI8D6XT1L+9bSWXckgkjTLw==
928+
dependencies:
929+
"@types/node" "*"
930+
"@types/source-list-map" "*"
931+
source-map "^0.6.1"
932+
933+
"@types/webpack@^4.4.31":
934+
version "4.41.12"
935+
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.12.tgz#0386ee2a2814368e2f2397abb036c0bf173ff6c3"
936+
integrity sha512-BpCtM4NnBen6W+KEhrL9jKuZCXVtiH6+0b6cxdvNt2EwU949Al334PjQSl2BeAyvAX9mgoNNG21wvjP3xZJJ5w==
937+
dependencies:
938+
"@types/anymatch" "*"
939+
"@types/node" "*"
940+
"@types/tapable" "*"
941+
"@types/uglify-js" "*"
942+
"@types/webpack-sources" "*"
943+
source-map "^0.6.0"
944+
902945
"@vue/babel-helper-vue-jsx-merge-props@^1.0.0", "@vue/babel-helper-vue-jsx-merge-props@^1.0.0-beta.3":
903946
version "1.0.0"
904947
resolved "https://registry.yarnpkg.com/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.0.0.tgz#048fe579958da408fb7a8b2a3ec050b50a661040"
@@ -2160,12 +2203,13 @@ class-utils@^0.3.5:
21602203
isobject "^3.0.0"
21612204
static-extend "^0.1.1"
21622205

2163-
clean-webpack-plugin@^0.1.19:
2164-
version "0.1.19"
2165-
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-0.1.19.tgz#ceda8bb96b00fe168e9b080272960d20fdcadd6d"
2166-
integrity sha512-M1Li5yLHECcN2MahoreuODul5LkjohJGFxLPTjl3j1ttKrF5rgjZET1SJduuqxLAuT1gAPOdkhg03qcaaU1KeA==
2206+
clean-webpack-plugin@^3.0.0:
2207+
version "3.0.0"
2208+
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-3.0.0.tgz#a99d8ec34c1c628a4541567aa7b457446460c62b"
2209+
integrity sha512-MciirUH5r+cYLGCOL5JX/ZLzOZbVr1ot3Fw+KcvbhUb6PM+yycqd9ZhIlcigQ5gl+XhppNmw3bEFuaaMNyLj3A==
21672210
dependencies:
2168-
rimraf "^2.6.1"
2211+
"@types/webpack" "^4.4.31"
2212+
del "^4.1.1"
21692213

21702214
cli-cursor@^3.1.0:
21712215
version "3.1.0"
@@ -7433,7 +7477,7 @@ rgba-regex@^1.0.0:
74337477
resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3"
74347478
integrity sha1-QzdOLiyglosO8VI0YLfXMP8i7rM=
74357479

7436-
rimraf@2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.3:
7480+
rimraf@2, rimraf@^2.5.4, rimraf@^2.6.3:
74377481
version "2.7.1"
74387482
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
74397483
integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==

0 commit comments

Comments
 (0)