-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.js
61 lines (56 loc) · 1.76 KB
/
webpack.base.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
const path = require('path');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");
const WebpackBeforeBuildPlugin = require('before-build-webpack');
const StyleExtHtmlWebpackPlugin = require("style-ext-html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: './src/index.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.(png|svg|jpg|gif|mp3|ogg)$/,
use: 'file-loader'
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
]
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ]
},
output: {
filename: 'app.js',
path: path.resolve(__dirname, 'dist')
},
// https://webpack.js.org/guides/hot-module-replacement/
plugins: [
new WebpackBeforeBuildPlugin(function(stats, callback) {
// ...
}, ['versionPatch']),
new CleanWebpackPlugin({ verbose:true }),
new CopyPlugin({
patterns: [
{ from: "assets" },
],
options: {
concurrency: 100,
},
}),
new HtmlWebpackPlugin({ title: `Game version v${JSON.stringify(require('./package.json').version)}` }),
new MiniCssExtractPlugin({
linkType: "text/css",
}),
new StyleExtHtmlWebpackPlugin(),
new webpack.HotModuleReplacementPlugin()
]
};