This repository was archived by the owner on Jul 15, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
96 lines (83 loc) · 2.09 KB
/
Copy pathwebpack.config.js
File metadata and controls
96 lines (83 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const path = require('path');
const loader = require('sass-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const baseEntries = [
__dirname + '/frontend/src/main/scss/styles.scss'
]
const productionEntries = baseEntries.concat([
__dirname + '/frontend/target/scala-3.1.1/frontend-opt/main.js',
]);
const developmentEntries = baseEntries.concat([
__dirname + '/frontend/target/scala-3.1.1/frontend-fastopt/main.js',
]);
var config = {
mode: 'development',
entry: developmentEntries,
plugins: [
new MiniCssExtractPlugin({
filename: 'style.css'
}),
new CleanWebpackPlugin({
verbose: true
}),
new HtmlWebpackPlugin({
inject: true,
title: 'loglog for RTV 356',
publicPath: '/',
template: './frontend/src/main/html/index.html'
})
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
devServer: {
static: './dist',
hot: true
},
optimization: {
runtimeChunk: 'single',
splitChunks: { chunks: 'all'},
},
module: {
rules: [
{
test: new RegExp("\\.js$"),
enforce: "pre",
use: ["source-map-loader"]
},
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader",
exclude: [/node_modules/, /build/, /__test__/, /__zio__/]
},
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "sass-loader",
options: {
sourceMap: true,
sassOptions: { outputStyle: "compressed" },
},
}],
}
]
},
ignoreWarnings: [/Failed to parse source map/],
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'source-map';
}
if (argv.mode === 'production') {
config.entry = productionEntries;
config.output.filename = '[name].[contenthash].js';
}
return config;
};