-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
24 lines (19 loc) · 834 Bytes
/
next.config.js
File metadata and controls
24 lines (19 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const webpack = require('webpack');
const withSass = require('@zeit/next-sass');
const isProduction = (process.env.NODE_ENV || 'production') === 'production';
module.exports = withSass({
webpack(config) {
const newConfig = Object.assign({}, config);
const envs = [{ name: 'NODE_ENV', default: 'development' }, 'API_URL', 'BASE_PATH'];
const definePluginOptions = {};
envs.forEach(e => {
const envName = typeof e === 'object' ? e.name : e;
const envValue = process.env[envName] || (typeof e === 'object' ? e.default : undefined);
definePluginOptions[`process.env.${envName}`] = JSON.stringify(envValue);
});
// @ts-ignore
newConfig.plugins.push(new webpack.DefinePlugin(definePluginOptions));
return newConfig;
},
assetPrefix: isProduction ? process.env.BASE_PATH : '',
});