This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
72 lines (70 loc) · 1.69 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
const path = require('path')
const webpack = require('webpack')
const HTMLPlugin = require('html-webpack-plugin')
module.exports = {
context: `${__dirname}/src`,
resolve: {
modules: ['src', 'node_modules'],
alias: { res: `${__dirname}/res` },
},
entry: {
app: './app.js',
},
output: {
clean: true,
path: `${__dirname}/dist`,
publicPath: `${process.env.WEBPACK_PUBLIC || ''}`,
filename: '[name]-[chunkhash:8].js',
assetModuleFilename: '[name]-[hash][ext]',
},
module: {
rules: [{
test: /\.js$/,
include: [
path.resolve(__dirname, 'src'),
path.dirname(require.resolve('rui/package.json')),
path.dirname(require.resolve('lib/package.json')),
path.dirname(require.resolve('whatwg-fetch/package.json')),
],
loader: 'babel-loader',
}, {
// test: path.resolve(__dirname, 'res'),
test: /\.(png|jpg|gif)$/i,
type: 'asset/resource',
}, {
resourceQuery: /raw/,
type: 'asset/source',
}, {
test: /\.val$/,
loader: 'val-loader',
}, {
resourceQuery: /emit/,
type: 'asset/source',
}, {
resourceQuery: /emit=([\w\.]+)/,
generator: {
filename: ({ filename }) => {
return filename.split('?')[1].match(/emit=([\w\.]+)/)?.[1]
},
},
}],
},
plugins: [
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env),
}),
new webpack.ProvidePlugin({
fetch: ['whatwg-fetch', 'fetch'],
}),
new HTMLPlugin({
template: 'index.html.ejs',
}),
],
experiments: {
topLevelAwait: true,
},
snapshot: {
// enable node_modules reloading
managedPaths: [],
},
}