-
Notifications
You must be signed in to change notification settings - Fork 99
/
next.config.js
74 lines (67 loc) · 2.49 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
74
const { parsed: localEnv } = require('dotenv').config()
const withGraphql = require('next-plugin-graphql')
const webpack = require('webpack')
const path = require('path')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withGraphql(
withBundleAnalyzer({
include: path.resolve(__dirname, './public/pictograms'),
// to expose ENV variables to the client side
webpack: (config, { isServer, dev }) => {
config.plugins.push(
new webpack.EnvironmentPlugin(localEnv || { ENV: 'prod' })
)
// ANT DESIGN
// used to minimise bundle size by 500KB
const alias = config.resolve.alias || {}
alias['@ant-design/icons/lib/dist$'] = path.resolve(
__dirname,
'./src/components/Icons.js'
)
config.resolve.alias = alias
if (isServer) {
const antStyles = /antd\/.*?\/style\/css.*?/
const origExternals = [...config.externals]
config.externals = [
(context, request, callback) => {
if (request.match(antStyles)) return callback()
if (typeof origExternals[0] === 'function') {
origExternals[0](context, request, callback)
} else {
callback()
}
},
...(typeof origExternals[0] === 'function'
? []
: origExternals),
]
config.module.rules.unshift({
test: antStyles,
use: 'null-loader',
})
}
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
icon: true,
},
},
],
})
return config
},
env: {
ENV: process.env.NODE_ENV,
AUTH0_DOMAIN: process.env.AUTH0_DOMAIN,
AUTH0_CLIENTID: process.env.AUTH0_CLIENTID,
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE,
AUTH0_CALLBACK: process.env.AUTH0_CALLBACK,
GRAPHQL_URL: process.env.GRAPHQL_URL,
},
})
)