-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.common.js
executable file
·73 lines (72 loc) · 1.83 KB
/
webpack.common.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
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FontminPlugin = require('fontmin-webpack');
const webpack = require('webpack');
const fs = require('fs');
const srcPath = fs.existsSync('./src') ? './src' : '.';
module.exports = {
entry: {
app: `${srcPath}/index.tsx`,
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: `${srcPath}/assets/index.html`
}),
new FontminPlugin({
autodetect: true, // automatically pull unicode characters from CSS
glyphs: ['\uf077', '\uf110'],
}),
new webpack.ids.HashedModuleIdsPlugin(), // so that file hashes don't change unexpectedly
// Ignore all locale files of moment.js
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/
}),
],
output: {
filename: '[name].[chunkhash:8].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
optimization: {
minimize: false
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.s[ac]ss$/i,
use: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.(jpe?g|png|gif|ico)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
type: 'asset/resource'
},
{
test: /\.(eot|otf|ttf|woff|woff2)$/,
exclude: /node_modules/,
type: 'asset/resource',
generator: {
filename: 'fonts/[name][ext]'
}
},
{
test: /\.(txt|xml)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
},
{
test: /\.svg$/,
use: ['@svgr/webpack']
}
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
}
};