-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathnext.config.js
64 lines (58 loc) · 1.6 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
const {
PHASE_DEVELOPMENT_SERVER
} = require('next/constants')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.BUNDLE_ANALYZE === 'true'
})
const { GitRevisionPlugin } = require('git-revision-webpack-plugin')
const basePath = process.env.BASE_PATH || ''
let version = 'unknown'
try {
version = new GitRevisionPlugin().commithash() || 'unknown'
} catch (e) {}
const nextConfig = (phase) => {
return {
transpilePackages: ['lodash-es'],
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: 'crafatar.com',
pathname: '**'
}
]
},
basePath,
assetPrefix: basePath
}
}
module.exports = (phase, { defaultConfig }) => {
const plugins = [
withBundleAnalyzer
]
return plugins.reduce((acc, plugin) => plugin(acc), { ...nextConfig(phase) })
}