-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.mjs
105 lines (97 loc) · 2.58 KB
/
webpack.config.mjs
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import webpack from 'webpack'
import path from 'path'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import dotenv from 'dotenv'
const __dirname = path.dirname(new URL(import.meta.url).pathname)
dotenv.config({ path: path.join(__dirname, './.env') })
const buildAsSubmodule = process.env.build_map_as_submodule === 'true'
const exclusions = buildAsSubmodule ? /node_modules/ : /node_modules\/(?!@defra*)/
const floodMapPath = buildAsSubmodule
? 'defra-map/src/flood-map.js'
: 'node_modules/@defra/flood-map/src/flood-map.js'
const arcGisPackagePath = buildAsSubmodule
? path.resolve(__dirname, 'defra-map/node_modules/@arcgis')
: '@arcgis'
console.log('Building defra-map as', buildAsSubmodule ? 'a submodule' : 'an npm package', '\n')
export default {
entry: {
main: [
path.join(__dirname, 'client/js/defra-map/index.js'),
path.join(__dirname, 'client/sass-flood-map/main.scss')
],
'check-your-details-map': [
path.join(__dirname, 'client/js/modules/check-your-details-map.js'),
path.join(__dirname, 'client/sass/check-your-details/index.scss')
]
},
devtool: 'source-map',
mode: 'development',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
optimization: {
splitChunks: {
chunks () {
return false
}
}
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new webpack.NormalModuleReplacementPlugin(
/js\/provider\/os-maplibre\/provider\.js/,
'./js/provider/esri-sdk/provider.js'
)
],
module: {
rules: [
{
test: /\.jsx?$/i,
exclude: exclusions,
loader: 'babel-loader'
},
{
test: /\.s?css$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader'
]
},
{ // Not Required anymore as the svgs are embedded inline
test: /\.(jpg|png)$/,
use: {
loader: 'url-loader'
}
},
{
test: /\.jsx?$/,
use: ['magic-comments-loader'],
exclude: exclusions
}
]
},
resolve: {
extensions: ['.jsx', '.js'],
alias: {
'/assets': path.resolve(__dirname, 'node_modules/govuk-frontend/dist/govuk/assets'),
'/flood-map': path.resolve(__dirname, floodMapPath),
'/@arcgis-path': arcGisPackagePath
}
},
ignoreWarnings: [
{
/* ignore scss warnings for now */
module: /main\.scss/
}
],
target: ['web', 'es5'],
performance: {
// hints: false,
maxEntrypointSize: 2048000,
maxAssetSize: 2048000
}
}