Hygiene: replace call to rm with clean-webpack-plugin

The invocation of `rm -rf resources/dist` in package.json
(`check-built-assets`) is replaced with clean-webpack-plugin.
The benefit of this change is that calling `npm run build` now works the
same as the `check-built-assets` script.

Bug: T193522
Change-Id: I64f048855ddceb7159279671b2174a7937e169ff
This commit is contained in:
Stephen Niedzielski 2018-06-18 09:09:28 -05:00
parent 3e248d75cc
commit fe2c3b23ee
3 changed files with 2414 additions and 2390 deletions

4798
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -9,7 +9,7 @@
"test": "npm run check-built-assets && npm run test:dev && npm run doc", "test": "npm run check-built-assets && npm run test:dev && npm run doc",
"doc": "jsdoc -c jsdoc.json", "doc": "jsdoc -c jsdoc.json",
"doc:start": "nodemon --watch src --exec 'npm run doc'", "doc:start": "nodemon --watch src --exec 'npm run doc'",
"check-built-assets": "echo 'CHECKING BUILD SOURCES ARE COMMITTED OR STAGED' && rm -rf resources/dist/ && npm run build && git diff -q resources/dist", "check-built-assets": "echo 'CHECKING BUILD SOURCES ARE COMMITTED OR STAGED' && npm run build && git diff -q resources/dist",
"coverage": "istanbul cover node_modules/.bin/mw-node-qunit tests/node-qunit/*.js tests/node-qunit/**/*.js", "coverage": "istanbul cover node_modules/.bin/mw-node-qunit tests/node-qunit/*.js tests/node-qunit/**/*.js",
"precommit": "npm run test:dev && npm run build && git add resources/dist && bundlesize" "precommit": "npm run test:dev && npm run build && git add resources/dist && bundlesize"
}, },
@ -18,6 +18,7 @@
"babel-preset-env": "1.6.0", "babel-preset-env": "1.6.0",
"babel-register": "6.24.1", "babel-register": "6.24.1",
"bundlesize": "0.15.3", "bundlesize": "0.15.3",
"clean-webpack-plugin": "0.1.19",
"eslint-config-wikimedia": "0.5.0", "eslint-config-wikimedia": "0.5.0",
"grunt": "1.0.2", "grunt": "1.0.2",
"grunt-banana-checker": "0.6.0", "grunt-banana-checker": "0.6.0",

View file

@ -1,6 +1,7 @@
/* global __dirname, process */ /* global __dirname, process */
const path = require( 'path' ), const path = require( 'path' ),
webpack = require( 'webpack' ), webpack = require( 'webpack' ),
CleanPlugin = require( 'clean-webpack-plugin' ),
PUBLIC_PATH = '/w/extensions/Popups', PUBLIC_PATH = '/w/extensions/Popups',
isProduction = process.env.NODE_ENV === 'production'; isProduction = process.env.NODE_ENV === 'production';
@ -62,6 +63,8 @@ const conf = {
] ]
}, },
plugins: [ plugins: [
new CleanPlugin( 'resources/dist', { verbose: false } ),
// To generate identifiers that are preserved over builds, webpack supplies // To generate identifiers that are preserved over builds, webpack supplies
// the NamedModulesPlugin (generates comments with file names on bundle) // the NamedModulesPlugin (generates comments with file names on bundle)
// https://webpack.js.org/guides/caching/#deterministic-hashes // https://webpack.js.org/guides/caching/#deterministic-hashes