Adjust webpack config slightly for better generation.

This commit is contained in:
projectmoon 2021-01-09 13:32:08 +00:00
parent a34e8d24c6
commit ee892a3f34
3 changed files with 9 additions and 4 deletions

View File

@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "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: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" "build:webpack": "webpack"
}, },

View File

@ -5,6 +5,7 @@ import * as api from "../api";
// changes to the server as the user makes them. // changes to the server as the user makes them.
(async () => { (async () => {
// Useful for making sure elements actually exist in event handler.
type Option<T> = T | null | undefined; type Option<T> = T | null | undefined;
const [, , USERNAME, CHARACTER_ID] = window.location.pathname.split('/'); const [, , USERNAME, CHARACTER_ID] = window.location.pathname.split('/');

View File

@ -31,8 +31,8 @@ module.exports = {
}, },
mode: "development", mode: "development",
output: { output: {
path: `${root}/generated/scripts/dist`, path: `${root}/generated`,
filename: '[name].bundle.js' filename: 'scripts/dist/[name].bundle.js'
}, },
devtool: 'inline-source-map', devtool: 'inline-source-map',
module: { module: {
@ -49,7 +49,11 @@ module.exports = {
extensions: [".ts", ".js"] extensions: [".ts", ".js"]
}, },
plugins: [ plugins: [
new CleanWebpackPlugin(), new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['!templates/**/*'],
cleanAfterEveryBuildPatterns: ['!templates/**/*'],
dry: false
}),
packPage('login.html.tera'), packPage('login.html.tera'),
packPage('base.html.tera'), packPage('base.html.tera'),
packPage('error.html.tera'), packPage('error.html.tera'),