-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
59 lines (53 loc) · 1.47 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
const { parsed: localEnv } = require('dotenv').config()
const withSourceMaps = require('@zeit/next-source-maps')
const withImages = require('next-images')
const withPlugins = require('next-compose-plugins')
const withBundleAnalyzer = require('@zeit/next-bundle-analyzer')
const { nextI18NextRewrites } = require('next-i18next/rewrites')
const localeSubpaths = {}
const plugins = [
withSourceMaps,
withImages,
[
withBundleAnalyzer,
{
analyzeServer: ['server', 'both'].includes(process.env.BUNDLE_ANALYZE),
analyzeBrowser: ['browser', 'both'].includes(process.env.BUNDLE_ANALYZE),
bundleAnalyzerConfig: {
server: {
analyzerMode: 'static',
reportFilename: '../server-analyze.html',
},
browser: {
analyzerMode: 'static',
reportFilename: 'client-analyze.html',
},
},
},
],
]
module.exports = withPlugins([...plugins], {
rewrites: async () => nextI18NextRewrites(localeSubpaths),
publicRuntimeConfig: {
localeSubpaths,
},
webpack: (config) => {
const conf = config
const originalEntry = config.entry
conf.node = {
fs: 'empty',
}
conf.entry = async () => {
const entries = await originalEntry()
if (
entries['main.js'] &&
!entries['main.js'].includes('./polyfills/index.js')
) {
entries['main.js'].unshift('./polyfills/index.js')
}
return entries
}
return conf
},
env: localEnv,
})