only load modules if we are in production

This commit is contained in:
Raphael 2023-11-27 16:36:15 +01:00
parent c634ef04d1
commit 7e2c08bdd6
2 changed files with 30 additions and 13 deletions

View File

@ -45,11 +45,7 @@
"signature_pad": "^4.0.1", "signature_pad": "^4.0.1",
"socket.io-client": "^4.4.0", "socket.io-client": "^4.4.0",
"uuid": "^8.1.0", "uuid": "^8.1.0",
"webdav": "^5.3.0", "webdav": "^5.3.0"
"webpack-dev-server": "^4.7.3",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.2",
"webpack-merge": "^5.8.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.16.8", "@babel/cli": "^7.16.8",
@ -76,7 +72,11 @@
"prettier": "^2.5.1", "prettier": "^2.5.1",
"pretty-quick": "^2.0.1", "pretty-quick": "^2.0.1",
"style-loader": "^1.1.4", "style-loader": "^1.1.4",
"vanilla-picker": "^2.12.1" "vanilla-picker": "^2.12.1",
"webpack-dev-server": "^4.7.3",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.2",
"webpack-merge": "^5.8.0"
}, },
"author": "Cracker0dks", "author": "Cracker0dks",
"license": "MIT", "license": "MIT",

View File

@ -1,6 +1,14 @@
import webpack from "webpack"; import webpack from "webpack";
import WebpackDevServer from "webpack-dev-server"; import WebpackDevServer from "webpack-dev-server";
import config from "../config/webpack.dev.js"; import config from "../config/webpack.dev.js";
import { getArgs } from "./utils.js";
const args = getArgs();
if (typeof args.mode === "undefined") {
// default to production mode
args.mode = "production";
}
const devServerConfig = { const devServerConfig = {
hot: true, hot: true,
@ -15,7 +23,12 @@ const devServerConfig = {
}, },
}; };
export default function startFrontendDevServer(port) { let startFrontendDevServer = function() {}
if (args.mode === "production") {
console.log("Not loading webpack-dev-server because of production mode!");
} else {
startFrontendDevServer = function(port) {
new WebpackDevServer(webpack(config), devServerConfig).start(port, (err) => { new WebpackDevServer(webpack(config), devServerConfig).start(port, (err) => {
if (err) { if (err) {
console.log(err); console.log(err);
@ -24,3 +37,7 @@ export default function startFrontendDevServer(port) {
console.log("Listening on port " + port); console.log("Listening on port " + port);
}); });
} }
}
export default startFrontendDevServer;