-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.ts
87 lines (85 loc) · 2.64 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
87
/* eslint @typescript-eslint/no-var-requires: off */
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const htmlTemplate = './source/template.html.ejs';
module.exports = {
entry: {
main: './source/ts/main.ts',
secondary: './source/ts/secondary.ts',
},
output: {
filename: '[name].[contenthash].mjs',
path: path.resolve(__dirname, 'build'),
},
devServer: {
contentBase: './build',
port: 8082,
},
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.tsx?$/i,
use: {
loader: 'babel-loader',
},
},
],
},
plugins: [
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [
{ from: 'source/icon.svg', to: 'icon.svg' },
{ from: 'source/icon-16.png', to: 'icon-16.png' },
{ from: 'source/icon-32.png', to: 'icon-32.png' },
{ from: 'source/icon-180.png', to: 'icon-180.png' },
{ from: 'source/robots.txt', to: 'robots.txt' },
],
}),
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
}),
new HtmlWebpackPlugin({
chunks: ['main'],
filename: 'index.html',
isReactApp: true,
template: htmlTemplate,
title: 'Hexagony',
}),
new HtmlWebpackPlugin({
chunks: ['secondary'],
filename: 'about.html',
hasReactHeader: true,
isReactApp: true,
template: htmlTemplate,
title: 'About',
}),
new HtmlWebpackPlugin({
chunks: ['secondary'],
filename: '403.html',
hasReactHeader: true,
isErrorMessage: true,
template: htmlTemplate,
title: '403 Forbidden',
}),
new HtmlWebpackPlugin({
chunks: ['secondary'],
filename: '404.html',
hasReactHeader: true,
isErrorMessage: true,
template: htmlTemplate,
title: '404 Not Found',
}),
],
resolve: {
// Seems to help to find files for imports when extension is not specified.
extensions: ['.ts', '.tsx', '.js']
}
};