A starting point for webpack with TypeScript + SASS/SCSS + EJS
Run init.sh to add/update all dependencies.
When developing, run the start script.
yarn startor for npm:
npm run startTo build for production, run the build script.
yarn buildor for npm
npm run buildThe webpack config is split up into three files:
webpack.common.js: Common configuration betweendevelopmentandproducrionbuilds.webpack.dev.js: Development specific configuration; gets called when running thestartandwatchscripts.webpack.prod.js: Production specific conficonfiguration; gets called when runningbuild.
By default (if you don't specify any loader in any way) a
fallback ejs loader from html-webpack-plugin kicks in
and loads the src/index.html file.
Please note that this loader does not support the full ejs syntax
as it is based on lodash template.
You can specify a loader via htmlWebpackOptions.js. For
example, to use handlebars-loader:
/** @type {import("html-webpack-plugin").Options} */
const options = {
template: "!!handlebars-loader!src/index.html",
title: "Webpack Starter",
};
module.exports = options;Note that you need to install handlebars and handlebars-loader via
yarn add -D handlebars handlebars-loaderFor more customization you can look into the declaration of HtmlWebpackPlugin.Options