2018-01-16 20:48:34 +01:00
|
|
|
const path = require("path");
|
|
|
|
const webpack = require("webpack");
|
2021-04-23 10:45:30 +02:00
|
|
|
const { merge } = require("webpack-merge");
|
2018-01-16 20:48:34 +01:00
|
|
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
2020-05-08 18:09:34 +02:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2021-12-09 20:29:24 +01:00
|
|
|
const { AngularWebpackPlugin } = require("@ngtools/webpack");
|
2022-03-22 10:09:19 +01:00
|
|
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
|
|
|
|
|
|
const NODE_ENV = process.env.NODE_ENV == null ? "development" : process.env.NODE_ENV;
|
2018-01-16 20:48:34 +01:00
|
|
|
|
2018-01-23 19:59:01 +01:00
|
|
|
const common = {
|
2018-01-16 20:48:34 +01:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2018-04-06 18:25:22 +02:00
|
|
|
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
|
2018-09-12 19:12:44 +02:00
|
|
|
loader: "@ngtools/webpack",
|
2018-01-16 20:48:34 +01:00
|
|
|
},
|
2018-01-30 23:24:02 +01:00
|
|
|
{
|
|
|
|
test: /\.(jpe?g|png|gif|svg)$/i,
|
2022-02-03 17:28:34 +01:00
|
|
|
exclude: /.*(bwi-font)\.svg/,
|
2021-12-09 20:29:24 +01:00
|
|
|
generator: {
|
2022-01-27 19:36:50 +01:00
|
|
|
filename: "images/[name][ext]",
|
2018-04-04 14:30:14 +02:00
|
|
|
},
|
|
|
|
type: "asset/resource",
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-09-12 19:12:44 +02:00
|
|
|
plugins: [],
|
|
|
|
resolve: {
|
2018-01-23 19:59:01 +01:00
|
|
|
extensions: [".tsx", ".ts", ".js"],
|
2018-04-04 14:30:14 +02:00
|
|
|
symlinks: false,
|
2022-06-02 15:18:29 +02:00
|
|
|
modules: [path.resolve("../../node_modules")],
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
output: {
|
2021-12-09 20:29:24 +01:00
|
|
|
filename: "[name].js",
|
2018-04-13 20:23:00 +02:00
|
|
|
path: path.resolve(__dirname, "build"),
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const renderer = {
|
2022-04-04 17:45:35 +02:00
|
|
|
mode: NODE_ENV,
|
2022-03-22 10:09:19 +01:00
|
|
|
devtool: "source-map",
|
2018-01-23 19:59:01 +01:00
|
|
|
target: "electron-renderer",
|
|
|
|
node: {
|
2018-09-12 19:12:44 +02:00
|
|
|
__dirname: false,
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
|
|
|
entry: {
|
2018-09-12 19:12:44 +02:00
|
|
|
"app/main": "./src/app/main.ts",
|
|
|
|
},
|
|
|
|
optimization: {
|
2022-03-22 10:09:19 +01:00
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
terserOptions: {
|
|
|
|
// Replicate Angular CLI behaviour
|
|
|
|
compress: {
|
|
|
|
global_defs: {
|
|
|
|
ngDevMode: false,
|
|
|
|
ngI18nClosureMode: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2018-09-12 19:12:44 +02:00
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
commons: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: "app/vendor",
|
|
|
|
chunks: (chunk) => {
|
|
|
|
return chunk.name === "app/main";
|
|
|
|
},
|
|
|
|
},
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
2018-01-23 19:59:01 +01:00
|
|
|
module: {
|
|
|
|
rules: [
|
2018-01-16 20:48:34 +01:00
|
|
|
{
|
|
|
|
test: /\.(html)$/,
|
2018-09-12 19:12:44 +02:00
|
|
|
loader: "html-loader",
|
2018-01-16 20:48:34 +01:00
|
|
|
},
|
2018-01-22 19:27:57 +01:00
|
|
|
{
|
|
|
|
test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
|
2018-02-02 18:01:55 +01:00
|
|
|
exclude: /loading.svg/,
|
2021-12-09 20:29:24 +01:00
|
|
|
generator: {
|
2022-01-27 19:36:50 +01:00
|
|
|
filename: "fonts/[name][ext]",
|
2021-12-09 20:29:24 +01:00
|
|
|
},
|
|
|
|
type: "asset/resource",
|
2018-01-23 19:59:01 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
2020-05-08 18:09:34 +02:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
publicPath: "../",
|
2018-09-12 19:12:44 +02:00
|
|
|
},
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
2020-05-08 18:09:34 +02:00
|
|
|
"css-loader",
|
2020-05-08 18:11:54 +02:00
|
|
|
"sass-loader",
|
2018-09-12 19:12:44 +02:00
|
|
|
],
|
2018-01-16 20:48:34 +01:00
|
|
|
},
|
2018-02-08 16:37:54 +01:00
|
|
|
// Hide System.import warnings. ref: https://github.com/angular/angular/issues/21560
|
2021-12-20 15:47:17 +01:00
|
|
|
{
|
2018-09-12 19:12:44 +02:00
|
|
|
test: /[\/\\]@angular[\/\\].+\.js$/,
|
2018-01-16 20:48:34 +01:00
|
|
|
parser: { system: true },
|
2020-05-08 18:11:54 +02:00
|
|
|
},
|
2018-09-12 19:12:44 +02:00
|
|
|
],
|
2021-12-20 15:47:17 +01:00
|
|
|
},
|
2018-01-16 20:48:34 +01:00
|
|
|
plugins: [
|
2021-12-09 20:29:24 +01:00
|
|
|
new AngularWebpackPlugin({
|
2021-05-05 09:47:35 +02:00
|
|
|
tsConfigPath: "tsconfig.renderer.json",
|
2018-04-06 18:25:22 +02:00
|
|
|
entryModule: "src/app/app.module#AppModule",
|
2018-09-12 19:12:44 +02:00
|
|
|
sourceMap: true,
|
2021-12-20 15:47:17 +01:00
|
|
|
}),
|
2018-09-12 19:12:44 +02:00
|
|
|
// ref: https://github.com/angular/angular/issues/20357
|
|
|
|
new webpack.ContextReplacementPlugin(
|
|
|
|
/\@angular(\\|\/)core(\\|\/)fesm5/,
|
2018-04-13 20:23:00 +02:00
|
|
|
path.resolve(__dirname, "./src")
|
2021-12-20 15:47:17 +01:00
|
|
|
),
|
2018-01-16 20:48:34 +01:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: "./src/index.html",
|
|
|
|
filename: "index.html",
|
2018-09-12 19:12:44 +02:00
|
|
|
chunks: ["app/vendor", "app/main"],
|
2021-12-20 15:47:17 +01:00
|
|
|
}),
|
2018-01-23 19:59:01 +01:00
|
|
|
new webpack.SourceMapDevToolPlugin({
|
2018-09-12 19:12:44 +02:00
|
|
|
include: ["app/main.js"],
|
2021-12-20 15:47:17 +01:00
|
|
|
}),
|
2020-05-08 18:09:34 +02:00
|
|
|
new MiniCssExtractPlugin({
|
2021-12-09 20:29:24 +01:00
|
|
|
filename: "[name].[contenthash].css",
|
|
|
|
chunkFilename: "[id].[contenthash].css",
|
2021-12-20 15:47:17 +01:00
|
|
|
}),
|
|
|
|
],
|
2018-01-16 20:48:34 +01:00
|
|
|
};
|
2018-01-23 19:59:01 +01:00
|
|
|
|
|
|
|
module.exports = merge(common, renderer);
|