From d5020d3f24cb748622d6dd35ca3e3342a9c186d4 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 27 Jan 2024 23:18:42 -0500 Subject: [PATCH] Add a production release build. --- .gitignore | 1 + package-lock.json | 3 ++- package.json | 9 ++++++--- webpack.config.js => webpack.common.js | 2 -- webpack.dev.js | 7 +++++++ webpack.prd.js | 6 ++++++ 6 files changed, 22 insertions(+), 6 deletions(-) rename webpack.config.js => webpack.common.js (96%) create mode 100644 webpack.dev.js create mode 100644 webpack.prd.js diff --git a/.gitignore b/.gitignore index 2ccbe46..b0a5c34 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules/ +/dist/ diff --git a/package-lock.json b/package-lock.json index f8d24ff..40fdc89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,8 @@ "typescript": "^5.3.3", "webpack": "^5.89.0", "webpack-cli": "^5.1.4", - "webpack-dev-server": "^4.15.1" + "webpack-dev-server": "^4.15.1", + "webpack-merge": "^5.10.0" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index b516b36..ecf7d29 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,10 @@ "description": "", "main": "index.jsx", "scripts": { - "dev": "webpack server", - "format": "prettier --write '**/*.{json,js,ts,tsx,css}'" + "dev": "webpack server --config webpack.dev.js", + "format": "prettier --write '**/*.{json,js,ts,tsx,css}'", + "build": "webpack --config webpack.dev.js", + "release": "webpack --config webpack.prd.js" }, "keywords": [], "author": "", @@ -30,6 +32,7 @@ "typescript": "^5.3.3", "webpack": "^5.89.0", "webpack-cli": "^5.1.4", - "webpack-dev-server": "^4.15.1" + "webpack-dev-server": "^4.15.1", + "webpack-merge": "^5.10.0" } } diff --git a/webpack.config.js b/webpack.common.js similarity index 96% rename from webpack.config.js rename to webpack.common.js index a1ce3fe..348c37e 100644 --- a/webpack.config.js +++ b/webpack.common.js @@ -75,8 +75,6 @@ module.exports = { filename: "index.html", }), ], - mode: "development", - devtool: "inline-source-map", experiments: { asyncWebAssembly: true, }, diff --git a/webpack.dev.js b/webpack.dev.js new file mode 100644 index 0000000..516e68b --- /dev/null +++ b/webpack.dev.js @@ -0,0 +1,7 @@ +const { merge } = require("webpack-merge"); +const common = require("./webpack.common.js"); + +module.exports = merge(common, { + mode: "development", + devtool: "inline-source-map", +}); diff --git a/webpack.prd.js b/webpack.prd.js new file mode 100644 index 0000000..80ceacd --- /dev/null +++ b/webpack.prd.js @@ -0,0 +1,6 @@ +const { merge } = require("webpack-merge"); +const common = require("./webpack.common.js"); + +module.exports = merge(common, { + mode: "production", +});