Visual Console Client: improved the cleaning of the build output dir

Former-commit-id: b92a726c0b098c73901feec53d872f9f25bc2fa1
This commit is contained in:
Alejandro Gallardo Escobar 2019-03-07 17:42:42 +01:00
parent 0dcbec64b4
commit c58dbf3d33
4 changed files with 53 additions and 23 deletions

View File

@ -1174,6 +1174,52 @@
}
}
},
"clean-webpack-plugin": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/clean-webpack-plugin/-/clean-webpack-plugin-2.0.0.tgz",
"integrity": "sha512-xH9RUgXaeeW2VmtygwcGNFAmYzRrv93uHk+c5gYA4qHmX1gpRfjScsvvCT7PcUb0Z5Y30H/pswTM1qYApVLBXA==",
"requires": {
"del": "^4.0.0"
},
"dependencies": {
"del": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/del/-/del-4.0.0.tgz",
"integrity": "sha512-/BnSJ+SuZyLu7xMn48kZY0nMXDi+5KNmR4g8n21Wivsl8+B9njV6/5kcTNE9juSprp0zRWBU28JuHUq0FqK1Nw==",
"requires": {
"globby": "^6.1.0",
"is-path-cwd": "^2.0.0",
"is-path-in-cwd": "^2.0.0",
"p-map": "^2.0.0",
"pify": "^4.0.1",
"rimraf": "^2.6.2"
}
},
"is-path-cwd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.0.0.tgz",
"integrity": "sha512-m5dHHzpOXEiv18JEORttBO64UgTEypx99vCxQLjbBvGhOJxnTNglYoFXxwo6AbsQb79sqqycQEHv2hWkHZAijA=="
},
"is-path-in-cwd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.0.0.tgz",
"integrity": "sha512-6Vz5Gc9s/sDA3JBVu0FzWufm8xaBsqy1zn8Q6gmvGP6nSDMw78aS4poBNeatWjaRpTpxxLn1WOndAiOlk+qY8A==",
"requires": {
"is-path-inside": "^1.0.0"
}
},
"p-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/p-map/-/p-map-2.0.0.tgz",
"integrity": "sha512-GO107XdrSUmtHxVoi60qc9tUl/KkNKm+X2CF4P9amalpGxv5YqVPJNfSb0wcA+syCopkZvYYIzW8OVTQW59x/w=="
},
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
}
}
},
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",

View File

@ -3,12 +3,9 @@
"version": "1.0.0",
"description": "Visual Console",
"scripts": {
"clean-build": "BUILD_PATH=\"pandora_console/include/visual-console\" node ./scripts/clean-build.js",
"prebuild": "npm run clean-build",
"build": "BUILD_PATH=\"pandora_console/include/visual-console\" NODE_ENV=production webpack",
"prebuild:dev": "npm run clean-build",
"build:dev": "BUILD_PATH=\"pandora_console/include/visual-console\" NODE_ENV=development webpack",
"build:watch": "BUILD_PATH=\"pandora_console/include/visual-console\" NODE_ENV=production webpack --watch",
"build:watch": "npm run build -- --watch",
"format": "prettier",
"lint": "eslint \"src/**/*.ts\"",
"start": "webpack-dev-server --color --mode=development",
@ -31,6 +28,7 @@
"@typescript-eslint/eslint-plugin": "^1.4.2",
"@typescript-eslint/parser": "^1.4.2",
"awesome-typescript-loader": "^5.2.1",
"clean-webpack-plugin": "^2.0.0",
"css-loader": "^2.1.0",
"eslint": "^5.14.1",
"eslint-config-prettier": "^4.0.0",

View File

@ -1,19 +0,0 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require("fs");
const buildPath = path.join(
__dirname,
"..",
"..",
process.env.BUILD_PATH && process.env.BUILD_PATH.length > 0
? process.env.BUILD_PATH
: "build"
);
if (fs.existsSync(buildPath)) {
fs.readdirSync(buildPath).forEach(file =>
fs.unlinkSync(path.join(buildPath, file))
);
}

View File

@ -1,6 +1,8 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const CleanWebpackPlugin = require("clean-webpack-plugin");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const dev = process.env.NODE_ENV !== "production";
@ -79,6 +81,9 @@ module.exports = {
]
},
plugins: [
// This plugin will remove all files inside Webpack's output.path directory,
// as well as all unused webpack assets after every successful rebuild.
new CleanWebpackPlugin(),
// Options for the plugin which extract the CSS files to build a main file.
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output