forked from cncf/landscapeapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
37 lines (28 loc) · 1.15 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
const path = require('path')
const { readFileSync } = require('fs')
const { load } = require('js-yaml')
const bundleAnalyzerPlugin = require('@next/bundle-analyzer')
const getBasePath = require('./tools/getBasePath')
const withBundleAnalyzer = bundleAnalyzerPlugin({ enabled: !!process.env.ANALYZE })
const projectPath = process.env.PROJECT_PATH
const lastUpdated = new Date().toISOString().substring(0, 19).replace('T', ' ') + 'Z'
const processedLandscape = load(readFileSync(path.resolve(projectPath, 'processed_landscape.yml')));
const tweets = (processedLandscape.twitter_options || {}).count || 0
const GA = process.env.GA
const basePath = getBasePath()
module.exports = withBundleAnalyzer({
env: { lastUpdated, tweets, GA, PROJECT_NAME: process.env.PROJECT_NAME },
basePath,
webpack: (config, options) => {
// CAREFUL before adding more presets, next/babel already includes some
// see https://nextjs.org/docs/advanced-features/customizing-babel-config
config.externals = [
...config.externals,
{ moment: 'moment' }
]
if (process.env.PREVIEW) {
config.optimization.minimize = false;
}
return config
},
})