-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
54 lines (50 loc) · 1.31 KB
/
webpack.config.js
File metadata and controls
54 lines (50 loc) · 1.31 KB
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
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import path from 'path'
import fs from 'fs'
import { fileURLToPath } from 'url'
const dirname = path.dirname(fileURLToPath(import.meta.url))
const entries = {}
fs.readdirSync('./src/main/js/')
.filter((fileName) => fileName.match(/.*\.js$/))
.forEach((fileName) => {
entries[fileName.replace(/\.js$/, '')] = [`./src/main/js/${fileName}`]
})
const config = {
entry: entries,
output: {
filename: 'bundle-[name].js',
path: path.resolve(dirname, 'src/main/resources/static/js'),
clean: true
},
devtool: 'source-map',
mode: 'development',
plugins: [
new MiniCssExtractPlugin({
filename: '../css/bundle-[name].css'
})
],
module: {
rules: [
{
test: /\.s?css$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{
test: /\.(png|svg|jpe?g|gif)$/i,
type: 'asset'
},
{
test: /\.(woff2?|eot|ttf|otf)$/i,
type: 'asset'
}
]
},
experiments: {
topLevelAwait: true
}
}
export default config