-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (59 loc) · 1.26 KB
/
webpack.config.js
File metadata and controls
61 lines (59 loc) · 1.26 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
55
56
57
58
59
60
61
const path = require("path")
const htmlWebpackPlugin = require('html-webpack-plugin')
//const postcssLoaderOptions = {
// loader: 'postcss-loader',
// options: {
// postcssOptions: {
// plugins: [
// 'postcss-preset-env',
// '@tailwindcss/postcss',
// ]
// }
// }
//}
function whichMode() {
return process.env.NODE_ENV === 'development'
? 'development'
: 'production'
}
module.exports = {
mode: whichMode(),
entry: './src/frontend/entry.js',
output: {
filename: 'script.js',
path: path.resolve(__dirname, 'public/'),
clean: {
keep(filename) {
const allowExtRegex = '/^.+\.(php|jsonc?)$/'
return Boolean(filename.matchAll(allowExtRegex))
},
},
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif|svg)$/,
type: 'asset/resource',
generator: {
filename: '[name][ext]',
outputPath: './assets/'
}
},
// {
// test: /\.s?(a|c)ss$/,
// use: [
// 'style-loader',
// 'css-loader',
// postcssLoaderOptions,
// 'sass-loader'
// ]
// }
]
},
plugins: [
new htmlWebpackPlugin({
template: './src/frontend/template.html'
})
]
// devtool: 'eval-cheap-module-source-map'
}