-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
101 lines (88 loc) · 2.16 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const getAbsPath = (pathStr) => path.resolve(__dirname, pathStr);
module.exports = {
mode: 'production',
entry: {
index: getAbsPath('src/index.ts'),
404: getAbsPath('src/404.ts'),
},
output: {
path: getAbsPath('dist'),
filename: '[name].bundle.[chunkhash].js',
},
devtool: 'source-map',
devServer: {
host: '0.0.0.0',
historyApiFallback: {
rewrites: [
{ from: /multitwitch\/.*/, to: '/404.html' },
{ from: /./, to: '/index.html' },
],
},
},
module: {
rules: [
// TYPESCRIPT
{ test: /\.tsx?$/, include: getAbsPath('src'), use: ['ts-loader'] },
// SCSS
{
test: /\.css$/,
include: getAbsPath('src'),
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [['postcss-nested', {}]],
},
},
},
],
},
// IMAGES
{
test: /\.(png|jpg|svg)$/,
include: getAbsPath('src'),
use: {
loader: 'url-loader',
options: {
name: '[name].[hash].[ext]',
},
},
},
// PUG
{
test: /\.pug$/,
include: getAbsPath('src'),
use: ['pug-loader'],
},
],
},
plugins: [
// contentash is the file's checksum, useful for caching purposes
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
}),
new HtmlWebpackPlugin({
inject: false,
template: getAbsPath('src/404.pug'),
chunks: ['404'],
filename: '404.html',
}),
new HtmlWebpackPlugin({
inject: false,
template: getAbsPath('src/index.pug'),
chunks: ['index'],
filename: 'index.html',
}),
],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
// Where to look when using things like "import 'lodash';"
modules: [getAbsPath('node_modules')],
},
};