-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
80 lines (77 loc) · 2.02 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
require('@babel/register');
module.exports = {
entry: ['./src/index.js'],
output: {
path: `${__dirname}/public`,
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
generatorOpts: { compact: false },
presets: ['@babel/preset-env']
}
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
hash: true
}),
new CopyWebpackPlugin({
patterns: [
{
from: './src/data',
to: './data',
filter: async (resourcePath) => {
// add your custom extension here if not listed
const texture = /\.(jpe?g|gif|png|svg|heic|pkm|pvr)$/;
const fnt = /\.(woff|woff2|ttf|fnt)$/;
const map = /\.(tmx|tsx)$/;
const audio =
/\.(wav|mp3|mpeg|opus|ogg|oga|wav|aac|caf|m4a|m4b|mp4|weba|webm|dolby|flac)$/;
const misc = /\.(xml|bin|glsl|ym|json|js)$/;
// only copy production files
const ret =
texture.test(resourcePath) ||
fnt.test(resourcePath) ||
map.test(resourcePath) ||
audio.test(resourcePath) ||
misc.test(resourcePath);
if (ret === false) {
// eslint-disable-next-line no-console
console.log(`ignoring data: ${resourcePath}`);
}
return ret;
}
}
]
})
],
resolve: {
modules: [path.resolve('./src'), path.resolve('./node_modules')]
},
devServer: {
static: {
directory: path.join(__dirname, 'public')
},
compress: true,
hot: true,
port: 9000
},
watch: false
};