-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
39 lines (36 loc) · 1.16 KB
/
next.config.js
File metadata and controls
39 lines (36 loc) · 1.16 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
const webpack = require('webpack') //eslint-disable-line
const path = require('path') //eslint-disable-line
const withPlugins = require('next-compose-plugins')
const withImages = require('next-images')
const withOffline = require('next-offline')
const withCSS = require('@zeit/next-css')
const withFonts = require('next-fonts')
const FRONTEND_ENV_KEYS = ['NODE_ENV', 'HOST']
if (process.env.HEROKU_APP_NAME) {
process.env.HOST = `https://${process.env.HEROKU_APP_NAME}.herokuapp.com`
}
const envPlugin = FRONTEND_ENV_KEYS.reduce(
(result, key) => ({
...result,
[`process.env.${key}`]: JSON.stringify(process.env[key]),
}),
{},
)
module.exports = withPlugins([withImages, withCSS, withFonts, withOffline], {
webpack: (config, { isServer }) => {
// adds access to specific env variables on front end
config.plugins.push(new webpack.DefinePlugin(envPlugin))
// Fixes npm packages that depend on `fs` module
if (!isServer) {
config.node = {
fs: 'empty',
}
}
config.plugins.push(
new webpack.ProvidePlugin({
cssTheme: path.resolve(path.join(__dirname, 'utils/cssTheme')),
}),
)
return config
},
})