Skip to content

Commit

Permalink
fix(plugins): issue with new version of clean webpack plugin
Browse files Browse the repository at this point in the history
The new version doesn't expect path, rather uses option to configure
itself. Pass in new option to keep the old behavior.
  • Loading branch information
swashata committed Apr 14, 2019
1 parent 655f188 commit b98c1b3
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 33 deletions.
1 change: 1 addition & 0 deletions packages/scripts/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@types/**
2 changes: 1 addition & 1 deletion packages/scripts/@types/cleanWebpackPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare module 'clean-webpack-plugin' {
import * as webpack from 'webpack';
export default class cleanWebpackPlugin extends webpack.Plugin {
constructor(config:string[], options: {[x:string]: boolean|string|string[]})
constructor(options: {[x:string]: boolean|string|string[]})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,22 @@ Array [
},
},
CleanWebpackPlugin {
"options": Object {
"allowExternal": false,
"dry": false,
"root": "/foo/bar",
"verbose": false,
},
"paths": Array [
"/foo/bar/dist/config1",
"apply": [Function],
"cleanAfterEveryBuildPatterns": Array [],
"cleanOnceBeforeBuildPatterns": Array [
"**/*",
],
"cleanStaleWebpackAssets": true,
"currentAssets": Array [],
"dangerouslyAllowCleanPatternsOutsideProject": false,
"dry": false,
"handleDone": [Function],
"handleInitial": [Function],
"initialClean": false,
"outputPath": "",
"protectWebpackAssets": true,
"removeFiles": [Function],
"verbose": false,
},
MiniCssExtractPlugin {
"options": Object {
Expand Down Expand Up @@ -238,15 +245,22 @@ Array [
},
},
CleanWebpackPlugin {
"options": Object {
"allowExternal": false,
"dry": false,
"root": "/foo/bar",
"verbose": false,
},
"paths": Array [
"/foo/bar/dist/config1",
"apply": [Function],
"cleanAfterEveryBuildPatterns": Array [],
"cleanOnceBeforeBuildPatterns": Array [
"**/*",
],
"cleanStaleWebpackAssets": true,
"currentAssets": Array [],
"dangerouslyAllowCleanPatternsOutsideProject": false,
"dry": false,
"handleDone": [Function],
"handleInitial": [Function],
"initialClean": false,
"outputPath": "",
"protectWebpackAssets": true,
"removeFiles": [Function],
"verbose": false,
},
MiniCssExtractPlugin {
"options": Object {
Expand Down
4 changes: 2 additions & 2 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"css-loader": "^2.1.1",
"del": "^4.1.0",
"dev-ip": "^1.0.1",
"enquirer": "^2.3.0",
"execa": "^1.0.0",
"figlet": "^1.2.1",
"figures": "^2.0.0",
Expand Down Expand Up @@ -94,7 +93,8 @@
"type-check:watch": "yarn type-check --watch",
"build:js": "babel ./src --out-dir lib --extensions '.ts,.tsx'",
"build:types": "tsc --emitDeclarationOnly",
"build": "yarn clean && yarn build:types && yarn build:js",
"build": "yarn clean && yarn build:types && yarn build:js",
"build:watch": "yarn clean && yarn build:js --watch",
"lint": "eslint src --ext='.ts,.js'",
"test": "jest --color",
"prepare": "cross-env NODE_ENV=production yarn build"
Expand Down
22 changes: 22 additions & 0 deletions packages/scripts/src/bin/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node
/**
* This file provides a cli helpline for developers to quickly check
* the output of different commands without touching the file-system.
*
* Check the source code for more documentation
*/

import program from 'commander';
import process from 'process';
import { Bootstrap } from '../scripts/Bootstrap';

program
.command('bootstrap')
.description('Check the CLI output of bootstrap command')
.action(async () => {
const bs = new Bootstrap(process.cwd(), '0.0.0-dev');
const answer = await bs.getUserInput();
console.log(JSON.stringify(answer, null, 4));
});

program.parse(process.argv);
6 changes: 4 additions & 2 deletions packages/scripts/src/config/WebpackConfigHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,11 @@ export class WebpackConfigHelper {
},
}),
// Clean dist directory
new CleanWebpackPlugin([`${this.outputPath}/${this.appDir}`], {
root: this.cwd,
new CleanWebpackPlugin({
verbose: false,
cleanAfterEveryBuildPatterns: `${this.outputPath}/${
this.appDir
}`,
}),
// Initiate mini css extract
new MiniCssExtractPlugin({
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2422,11 +2422,6 @@ ansi-colors@^3.0.0:
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.0.6.tgz#a0b9e00e8c1cc6685b1c3130dbeb9abed03ca6a4"
integrity sha512-rY3B55KSBMMARmGXtzaG5o+kqnCrEF99rngBq5fV+cbwJepVGhDT8eB7UhSDwsJxNsMzSQDLQAyWmgi9pfzssQ==

ansi-colors@^3.2.1:
version "3.2.4"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf"
integrity sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA==

ansi-escapes@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30"
Expand Down Expand Up @@ -5041,13 +5036,6 @@ enhanced-resolve@^4.1.0:
memory-fs "^0.4.0"
tapable "^1.0.0"

enquirer@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.0.tgz#c362c9d84984ebe854def63caaf12983a16af552"
integrity sha512-RNGUbRVlfnjmpxV+Ed+7CGu0rg3MK7MmlW+DW0v7V2zdAUBC1s4BxCRiIAozbYB2UJ+q4D+8tW9UFb11kF72/g==
dependencies:
ansi-colors "^3.2.1"

entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
Expand Down

0 comments on commit b98c1b3

Please sign in to comment.