-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.common.js
60 lines (53 loc) · 1.49 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
const merge = require('webpack-merge')
const path = require('path')
//https://webpack.js.org/plugins/html-webpack-plugin/
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src', 'index.html'),
filename: 'index.html',
inject: 'body',
minify: {
collapseWhitespace: true,
minifyCSS: true
}
})
const WebpackCleanupPlugin = require('webpack-cleanup-plugin')
const WebpackCleanupPluginConfig = new WebpackCleanupPlugin({})
//merge() isn't required, but it enables autocomplete
module.exports = merge({
entry: path.join(__dirname, 'src', 'main.ts'),
output: {
path: path.join(__dirname, 'public')
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [WebpackCleanupPluginConfig, HTMLWebpackPluginConfig],
module: {
rules: [
//https://www.typescriptlang.org/docs/handbook/react-&-webpack.html (ignore the react part)
{
test: /\.ts$/,
loader: 'awesome-typescript-loader'
},
//https://webpack.js.org/loaders/css-loader/
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
//https://webpack.js.org/loaders/file-loader/
{
test: /\.(gltf|mp3|svg|glb|png|jpe?g)$/,
use: [
{
loader: 'file-loader',
options: {
outputPath: 'assets',
name: '[sha256:hash:base64:16].[ext]'
}
}
]
}
]
}
})