This repository has been archived by the owner on Apr 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.js
85 lines (81 loc) · 2.33 KB
/
webpack.config.js
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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const FontminPlugin = require('fontmin-webpack');
/** @var {any} MiniCssExtractPlugin*/
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const entry = {
main: './js/main.js',
style: './js/style.js'
};
try {
const qunit = require('qunit');
if (qunit) {
entry.test = './tests/test.js';
}
} catch (e) {
process.stdout.write('Could not load qunit: "' + e + '"\n');
process.stdout.write("This is probably a production environment.\n");
}
module.exports = {
entry: entry,
output: {
filename: '[name].bundle.js',
publicPath: 'dist/',
clean: true
},
mode: 'production',
stats: 'minimal',
optimization: {
runtimeChunk: 'single',
},
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: './',
},
},
'css-loader',
],
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
type: 'asset/resource'
},
{
test: /\.(png|gif)$/,
type: 'asset/resource'
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'templates/index.html',
filename: '../index.html',
scriptLoading: 'defer',
inject: 'head',
excludeChunks: ['test']
}),
new HtmlWebpackPlugin({
template: 'templates/tests.html',
filename: '../tests/index.html',
publicPath: '../dist/',
inject: 'head',
chunks: ['test']
}),
new MiniCssExtractPlugin(),
new CssMinimizerPlugin(),
new FontminPlugin({
autodetect: false,
// Taken from https://fontawesome.com/cheatsheet.
glyphs: [
'\uf002', '\uf0b0', '\uf041', '\uf013', '\uf055', '\uf188', '\uf129', '\uf140',
'\uf111', '\uf1ce', '\uf192', '\uf05e', '\uf0c9', '\uf128',
],
}),
],
};