From ee892a3f341710a373cb942dca5d6d0c3a4c4991 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sat, 9 Jan 2021 13:32:08 +0000 Subject: [PATCH] Adjust webpack config slightly for better generation. --- package.json | 2 +- src/frontend/scripts/characters/edit.ts | 1 + webpack.config.js | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f550315..cc214af 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "webpack-dev": "webpack serve --watch --inline --port 8081 --host 0.0.0.0 --output-path=./build", + "webpack-dev": "webpack --watch", "build:protobuf": "mkdir -p src/frontend/_proto && protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts -I ./proto --js_out=import_style=commonjs,binary:./src/frontend/_proto --ts_out=service=grpc-web:./src/frontend/_proto ./proto/*.proto", "build:webpack": "webpack" }, diff --git a/src/frontend/scripts/characters/edit.ts b/src/frontend/scripts/characters/edit.ts index 26c4059..c89a817 100644 --- a/src/frontend/scripts/characters/edit.ts +++ b/src/frontend/scripts/characters/edit.ts @@ -5,6 +5,7 @@ import * as api from "../api"; // changes to the server as the user makes them. (async () => { + // Useful for making sure elements actually exist in event handler. type Option = T | null | undefined; const [, , USERNAME, CHARACTER_ID] = window.location.pathname.split('/'); diff --git a/webpack.config.js b/webpack.config.js index 2ea5bd0..4d7007e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -31,8 +31,8 @@ module.exports = { }, mode: "development", output: { - path: `${root}/generated/scripts/dist`, - filename: '[name].bundle.js' + path: `${root}/generated`, + filename: 'scripts/dist/[name].bundle.js' }, devtool: 'inline-source-map', module: { @@ -49,7 +49,11 @@ module.exports = { extensions: [".ts", ".js"] }, plugins: [ - new CleanWebpackPlugin(), + new CleanWebpackPlugin({ + cleanOnceBeforeBuildPatterns: ['!templates/**/*'], + cleanAfterEveryBuildPatterns: ['!templates/**/*'], + dry: false + }), packPage('login.html.tera'), packPage('base.html.tera'), packPage('error.html.tera'),