-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
60 lines (58 loc) · 1.52 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
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts')
const config = {
mode: 'production',
devtool: 'source-map',
resolve: {
extensions: ['.mjs']
},
entry: {
application: [
path.resolve(__dirname, 'app', 'assets', 'javascript', 'application.js'),
path.resolve(__dirname, 'app', 'assets', 'stylesheets', 'application.scss')
],
unlink: path.resolve(__dirname, 'app', 'assets', 'javascript', 'unlink.js'),
govuk_frontend: path.resolve(__dirname, 'app', 'assets', 'javascript', 'govuk-frontend.js')
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.mjs$/,
type: 'javascript/auto',
resolve: {
fullySpecified: false
}
},
{
test: /\.(?:sa|sc|c)ss$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
{
test: /\.(png|jpe?g|gif|eot|woff2|woff|ttf|svg|ico)$/i,
type: 'asset/resource'
}
]
},
plugins: [
new RemoveEmptyScriptsPlugin(),
new MiniCssExtractPlugin()
],
output: {
path: path.resolve(__dirname, 'app/assets/builds'),
filename: '[name].js',
assetModuleFilename: '[name][ext]',
chunkFilename: '[id].[chunkhash].js'
}
}
module.exports = config