forked from BaseAdresseNationale/adresse.data.gouv.fr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
62 lines (51 loc) · 1.5 KB
/
next.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
const {join} = require('path')
const nextRuntimeDotenv = require('next-runtime-dotenv')
const withConfig = nextRuntimeDotenv({
public: [
'BACKEND_URL',
'API_GEO_URL',
'BAN_DASHBOARD_URL',
'API_ADRESSE',
'API_EXPLORE_URL',
'API_EXPLORE_SEARCH_URL',
'PIWIK_URL',
'PIWIK_SITE_ID',
'BACKEND_PUBLICATION'
]
})
const commonModules = [
'/node_modules/fbjs/',
'/node_modules/next/',
'/node_modules/lodash/',
'/node_modules/webpack/',
'/components/hoc/',
'/pages/_error.js'
]
module.exports = withConfig({
webpack(config, {dev, isServer}) {
// eslint-disable-next-line import/no-extraneous-dependencies
const {ContextReplacementPlugin} = require('webpack')
config.plugins.push(
new ContextReplacementPlugin(/moment[/\\]locale$/, /fr/)
)
if (!dev && !isServer) {
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')
config.optimization.splitChunks.cacheGroups.shared = {
name: 'commons',
test: m => m.resource && commonModules.some(c =>
m.resource.startsWith(join(__dirname, c))
)
}
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
reportFilename: join(__dirname, 'reports/bundles.html'),
defaultSizes: 'gzip'
}))
}
// Fix jsonlint error when importing mapbox-gl-draw
// https://github.com/mapbox/mapbox-gl-draw/issues/626
config.node = {...config.node, fs: 'empty'}
return config
}
})