tenebrous-sheets/static/scripts/ts/webpack.config.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const root = path.resolve(__dirname, '..', '..', '..');
function packPage(page, chunks) {
if (!chunks) chunks = [];
return new HtmlWebpackPlugin({
2021-01-03 13:37:55 +00:00
template: `${root}/src/templates/${page}`,
filename: `${root}/static/templates/${page}`,
chunks: chunks,
inject: false,
minify: false
});
}
module.exports = {
entry: {
index: "./src/index.ts",
blah: "./src/blah.ts",
},
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: 'all',
},
},
mode: "development",
output: {
path: path.resolve(__dirname, 'build'),
filename: '[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(),
packPage('login.html.tera', ['index']),
packPage('base.html.tera'),
packPage('error.html.tera'),
packPage('index.html.tera'),
packPage('registration.html.tera'),
packPage('characters/edit_character.html.tera'),
packPage('characters/edit_character_macros.html.tera'),
packPage('characters/new_character.html.tera'),
packPage('characters/view_character.html.tera')
]
};