-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
86 lines (84 loc) · 2.33 KB
/
webpack.config.ts
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
import path from 'path'
import HtmlWebPackPlugin from 'html-webpack-plugin'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import TerserPlugin from 'terser-webpack-plugin'
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
import CopyPlugin from 'copy-webpack-plugin'
const configBuild = {
entry: {
main: './src/index.ts',
},
resolve: {
extensions: ['.ts'],
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: '[name].js',
assetModuleFilename: 'assets/[name][ext]',
clean: true,
hashFunction: 'sha256',
},
mode: 'production',
target: 'web',
optimization: {
minimize: true,
minimizer: [new TerserPlugin({}), new CssMinimizerPlugin()],
},
performance: {
hints: false,
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
include: [path.resolve(__dirname, 'src')],
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: {
minimize: true,
},
},
],
},
{
// Store as files
test: /\.(png|jpg)$/,
type: 'asset/resource',
},
{
// Loads vector and fonts in a base64 encoded URI
test: /\.(svg|woff|woff2|eot|ttf)$/,
type: 'asset/inline',
},
{
// SASS/SCSS to CSS
test: /\.s?css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
],
},
plugins: [
new HtmlWebPackPlugin({
template: './src/views/index.ejs',
filename: './index.html',
inject: false,
}),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css',
}),
new CopyPlugin({
patterns: [
{ from: 'src/assets/data', to: 'data/' },
{ from: 'src/assets/pages', to: './' },
],
}),
],
}
export default configBuild