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, '.'); console.log("root is", root); function packPage(page, chunks) { if (!chunks) chunks = []; return new HtmlWebpackPlugin({ template: `${root}/src/frontend/templates/${page}`, filename: `${root}/generated/templates/${page}`, publicPath: '/scripts/dist', scriptLoading: 'defer', chunks: chunks, inject: false, minify: false }); } module.exports = { entry: { edit_character: "./src/frontend/scripts/characters/edit.ts", }, 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 }), 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'), ] };