tenebrous-sheets/webpack.config.js

70 lines
2.0 KiB
JavaScript
Raw Normal View History

2021-01-09 12:57:13 +00:00
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
2021-01-24 14:40:34 +00:00
const CompressionPlugin = require("compression-webpack-plugin");
2021-01-09 12:57:13 +00:00
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const root = path.resolve(__dirname, '.');
function packPage(page, chunks) {
2021-01-24 14:40:34 +00:00
if (!chunks) chunks = [];
return new HtmlWebpackPlugin({
template: `${root}/src/frontend/templates/${page}`,
filename: `${root}/generated/templates/${page}`,
publicPath: '/',
scriptLoading: 'defer',
chunks: chunks,
inject: false,
minify: false
});
2021-01-09 12:57:13 +00:00
}
module.exports = {
2021-01-24 14:40:34 +00:00
entry: {
edit_character: "./src/frontend/scripts/characters/edit.ts",
2021-01-09 12:57:13 +00:00
},
2021-01-24 14:40:34 +00:00
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: 'all',
},
},
mode: "development",
output: {
path: `${root}/generated`,
filename: 'scripts/dist/[name].bundle.js'
},
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.ts$/,
include: /src|_proto/,
exclude: /node_modules/,
loader: "ts-loader"
}
]
},
resolve: {
extensions: [".ts", ".js"]
},
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['!templates/**/*'],
cleanAfterEveryBuildPatterns: ['!templates/**/*'],
dry: false
}),
new CompressionPlugin(),
packPage('login.html.tera'),
packPage('base.html.tera'),
packPage('error.html.tera'),
packPage('index.html.tera'),
packPage('registration.html.tera'),
packPage('characters/edit_character.html.tera', ['edit_character']),
packPage('characters/edit_character_macros.html.tera'),
packPage('characters/new_character.html.tera'),
packPage('characters/view_character.html.tera'),
packPage('characters/view_character_macros.html.tera'),
2021-01-09 12:57:13 +00:00
]
};