Skip to content

Commit 6cb4e33

Browse files
committed
When using the "clean" option, empty the dir, but don't remove it entirely
1 parent 3cb1de9 commit 6cb4e33

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lib/config-generator.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,9 @@ class ConfigGenerator {
344344

345345
if (this.webpackConfig.cleanupOutput) {
346346
plugins.push(
347-
new CleanWebpackPlugin([this.webpackConfig.outputPath], {
347+
new CleanWebpackPlugin(['**/*'], {
348+
root: this.webpackConfig.outputPath,
348349
verbose: false,
349-
/*
350-
* Instead of passing the "root" option and then making
351-
* the first argument (this.webpackConfig.outputPath) relative
352-
* to that (e.g. "builds"), we pass the absolute path as
353-
* the first argument. To the plugin, this looks like a
354-
* path that is "outside of the project root". This flag
355-
* says to ignore that.
356-
*/
357-
allowExternal: true
358350
})
359351
);
360352
}

lib/test/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ function emptyTmpDir() {
9494

9595
function touchFileInOutputDir(filename, webpackConfig) {
9696
const fullPath = path.join(webpackConfig.outputPath, filename);
97+
fs.ensureDirSync(path.dirname(fullPath));
98+
9799
fs.writeFileSync(
98100
fullPath,
99101
''

test/functional.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,16 @@ module.exports = {
554554
config.addEntry('main', './js/no_require');
555555
config.cleanupOutputBeforeBuild();
556556
testSetup.touchFileInOutputDir('file.txt', config);
557+
testSetup.touchFileInOutputDir('deeper/other.txt', config);
557558

558559
testSetup.runWebpack(config, (webpackAssert) => {
559560
// make sure the file was cleaned up!
560561
webpackAssert.assertOutputFileDoesNotExist(
561562
'file.txt'
562563
);
564+
webpackAssert.assertOutputFileDoesNotExist(
565+
'deeper/other.txt'
566+
);
563567

564568
done();
565569
});

0 commit comments

Comments
 (0)