-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnext.config.js
73 lines (69 loc) · 1.96 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
63
64
65
66
67
68
69
70
71
72
73
const withPlugins = require('next-compose-plugins');
const withBundleAnalyzer = require('@zeit/next-bundle-analyzer');
const withPWA = require('next-pwa');
const nextRuntimeDotenv = require('next-runtime-dotenv');
const withConfig = nextRuntimeDotenv({
public: [
'API_URL',
'API_KEY',
'CDN_URL',
'SITE_URL',
'ALGOLIA_ID',
'ALGOLIA_KEY',
'NEXT_PUBLIC_GA_ID',
'APPLE_CLIENT_ID',
],
});
const nextConfig = {
analyzeServer: ['server', 'both'].includes(process.env.BUNDLE_ANALYZE),
analyzeBrowser: ['browser', 'both'].includes(process.env.BUNDLE_ANALYZE),
bundleAnalyzerConfig: {
server: {
analyzerMode: 'static',
reportFilename: '../bundles/server.html',
},
browser: {
analyzerMode: 'static',
reportFilename: '../bundles/client.html',
},
},
publicRuntimeConfig: {
PROXY_MODE: process.env.PROXY_MODE,
API_URL: process.env.API_URL,
API_KEY: process.env.API_KEY,
CDN_URL: process.env.CDN_URL,
STATIC_PATH: process.env.STATIC_PATH,
SITE_URL: process.env.SITE_URL,
ALGOLIA_ID: process.env.ALGOLIA_ID,
ALGOLIA_KEY: process.env.ALGOLIA_KEY,
NEXT_PUBLIC_GA_ID: process.env.NEXT_PUBLIC_GA_ID,
APPLE_CLIENT_ID: process.env.APPLE_CLIENT_ID,
},
pwa: {
dest: 'public',
},
images: {
domains: ['cdn.surge.fm'],
},
cssModules: true,
cssLoaderOptions: { importLoaders: 1, localIdentName: '[local]___[hash:base64:5]' },
// lessLoaderOptions: {
// javascriptEnabled: true,
// },
webpack(config) {
config.module.rules.forEach(rule => {
if (String(rule.test) === String(/\.css$/)) {
rule.use.forEach(u => {
if (u.options) {
// eslint-disable-next-line no-param-reassign
u.options.modules = false;
}
});
}
});
return config;
},
};
const plugins = [[withBundleAnalyzer]];
if (process.env.PWA === '1') plugins.push([withPWA]);
module.exports = withConfig(withPlugins(plugins, nextConfig));