From 22dd766db3d91303e442a15c948ddec1965102fb Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Thu, 22 Jul 2021 20:25:41 -0500 Subject: [PATCH] Split webpack configuration to development and production. --- Props/Props.csproj | 4 ++-- Props/assets/scss/main.scss | 2 +- Props/package-lock.json | 15 +++++++++++---- Props/package.json | 11 +++++++---- Props/{webpack.config.js => webpack.common.js} | 14 +------------- Props/webpack.dev.js | 9 +++++++++ Props/webpack.prod.js | 9 +++++++++ 7 files changed, 40 insertions(+), 24 deletions(-) rename Props/{webpack.config.js => webpack.common.js} (83%) create mode 100644 Props/webpack.dev.js create mode 100644 Props/webpack.prod.js diff --git a/Props/Props.csproj b/Props/Props.csproj index a84b894..c32e0df 100644 --- a/Props/Props.csproj +++ b/Props/Props.csproj @@ -54,7 +54,7 @@ - - + + diff --git a/Props/assets/scss/main.scss b/Props/assets/scss/main.scss index 756bd4a..12d0d03 100644 --- a/Props/assets/scss/main.scss +++ b/Props/assets/scss/main.scss @@ -1,6 +1,6 @@ @use "themer"; -@use "~/node_modules/bootstrap/scss/bootstrap"; @use "sass:color"; +@use "~/node_modules/bootstrap/scss/bootstrap"; header > nav { @extend .navbar-expand-lg; diff --git a/Props/package-lock.json b/Props/package-lock.json index 1806247..bc5601f 100644 --- a/Props/package-lock.json +++ b/Props/package-lock.json @@ -67,6 +67,7 @@ "version": "7.14.7", "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.14.7.tgz", "integrity": "sha512-6WPwZqO5priAGIwV6msJcdc9TsEPzYeYdS/Xuoap+/ihkgN6dzHp2bcAAwyWZ5bLzk0vvjDmKvRwkqNaiJ8BiQ==", + "dev": true, "requires": { "eslint-scope": "^5.1.1", "eslint-visitor-keys": "^2.1.0", @@ -76,7 +77,8 @@ "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true } } }, @@ -2174,6 +2176,7 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, "requires": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" @@ -2199,7 +2202,8 @@ "eslint-visitor-keys": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==" + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true }, "espree": { "version": "7.3.1", @@ -2253,6 +2257,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, "requires": { "estraverse": "^5.2.0" }, @@ -2260,14 +2265,16 @@ "estraverse": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", - "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==" + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true } } }, "estraverse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true }, "esutils": { "version": "2.0.3", diff --git a/Props/package.json b/Props/package.json index 69050c2..f627a79 100644 --- a/Props/package.json +++ b/Props/package.json @@ -2,13 +2,16 @@ "private": true, "main": "js/index.js", "scripts": { - "build": "webpack" + "build": "webpack --config webpack.common.js", + "build:dev": "webpack --config webpack.dev.js", + "build:prod": "webpack --config webpack.prod.js" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "@babel/core": "^7.14.8", + "@babel/eslint-parser": "^7.14.7", "@babel/plugin-transform-runtime": "^7.14.5", "@babel/preset-env": "^7.14.8", "babel-eslint": "^10.1.0", @@ -21,10 +24,10 @@ "sass-loader": "^12.1.0", "style-loader": "^3.1.0", "webpack": "^5.45.1", - "webpack-cli": "^4.7.2" + "webpack-cli": "^4.7.2", + "webpack-merge": "^5.8.0" }, "dependencies": { - "@babel/eslint-parser": "^7.14.7", "@babel/runtime": "^7.14.8", "axios": "^0.21.1", "bootstrap": "^5.0.2", @@ -32,4 +35,4 @@ "popmotion": "^9.4.0", "simplebar": "^5.3.5" } -} +} \ No newline at end of file diff --git a/Props/webpack.config.js b/Props/webpack.common.js similarity index 83% rename from Props/webpack.config.js rename to Props/webpack.common.js index 75059af..2b85be0 100644 --- a/Props/webpack.config.js +++ b/Props/webpack.common.js @@ -58,16 +58,4 @@ let config = { ] }; -module.exports = (env, argv) => { - if (argv.mode === "development") { - // Development specific configuration. - config.devtool = "eval-source-map"; - } - - if (argv.mode === "production") { - // Production specific configuration. - config.devtool = "nosources-source-map"; - } - - return config; -}; +module.exports = config; diff --git a/Props/webpack.dev.js b/Props/webpack.dev.js new file mode 100644 index 0000000..abf38c3 --- /dev/null +++ b/Props/webpack.dev.js @@ -0,0 +1,9 @@ +const { merge } = require("webpack-merge"); +const common = require("./webpack.common"); + +let config = { + mode: "development", + devtool: "eval-source-map", +}; + +module.exports = merge(common, config); diff --git a/Props/webpack.prod.js b/Props/webpack.prod.js new file mode 100644 index 0000000..f0ac5fc --- /dev/null +++ b/Props/webpack.prod.js @@ -0,0 +1,9 @@ +const { merge } = require("webpack-merge"); +const common = require("./webpack.common"); + +let config = { + mode: "production", + devtool: "nosources-source-map", +}; + +module.exports = merge(common, config);