-
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathnext.config.js
More file actions
74 lines (67 loc) · 1.88 KB
/
next.config.js
File metadata and controls
74 lines (67 loc) · 1.88 KB
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
const {
PHASE_DEVELOPMENT_SERVER
} = require('next/constants')
let withBundleAnalyzer = (cfg) => cfg
if (process.env.BUNDLE_ANALYZE === 'true') {
withBundleAnalyzer = require('@next/bundle-analyzer')({ enabled: true })
}
const basePath = process.env.BASE_PATH || ''
let version = process.env.GIT_COMMIT || 'unknown'
if (version === 'unknown') {
try {
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
version = new GitRevisionPlugin().commithash() || 'unknown'
} catch (e) {}
}
const nextConfig = (phase) => {
return {
transpilePackages: ['lodash-es'],
modularizeImports: {
'react-icons/?(((\\w*)?/?)*)': {
transform: 'react-icons/{{ matches.[1] }}/index.js',
skipDefaultConversion: true
}
},
webpack (config) {
config.module.rules.push({
test: /\.(png|svg)$/i,
use: [{
loader: 'url-loader',
options: {
limit: 8192,
publicPath: './',
outputPath: 'static/css/',
name: '[name].[ext]',
esModule: false
}
}]
})
return config
},
env: {
GIT_COMMIT: version,
IS_DEV: (phase === PHASE_DEVELOPMENT_SERVER).toString(),
SERVER_FOOTER_NAME: process.env.SERVER_FOOTER_NAME || 'Missing SERVER_FOOTER_NAME env var',
BASE_PATH: basePath,
NOTIFICATION_VAPID_PUBLIC_KEY: process.env.NOTIFICATION_VAPID_PUBLIC_KEY || 'Missing NOTIFICATION_VAPID_PUBLIC_KEY env var'
},
poweredByHeader: false,
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'vzge.me',
pathname: '**'
}
]
},
basePath,
assetPrefix: basePath
}
}
module.exports = (phase, { defaultConfig }) => {
const plugins = [
withBundleAnalyzer
]
return plugins.reduce((acc, plugin) => plugin(acc), { ...nextConfig(phase) })
}