-
Notifications
You must be signed in to change notification settings - Fork 49
/
next.config.js
61 lines (56 loc) · 1.51 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
require('dotenv').config();
const path = require('path');
const env = {};
const publicRuntimeConfig = {};
const serverRuntimeConfig = {};
Object.keys(process.env || {}).forEach(key => {
switch (true) {
case key.startsWith('SERVER_'):
serverRuntimeConfig[key] = process.env[key];
break;
case key.startsWith('PUBLIC_'):
publicRuntimeConfig[key] = process.env[key];
break;
case key.startsWith('NODE_'):
case key.startsWith('__'):
case key.startsWith('npm_'):
case key === 'PATH':
case key === 'NODE':
// https://github.com/zeit/next.js/blob/master/errors/env-key-not-allowed.md
break;
default:
env[key] = process.env[key];
}
});
module.exports = {
env,
publicRuntimeConfig,
serverRuntimeConfig,
webpack(config, { isServer, defaultLoaders }) {
//
// Simplified from https://github.com/twopluszero/next-images/blob/master/index.js
//
config.module.rules.push({
test: /\.(jpe?g|png|svg|gif|ico|webp|mp4)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
publicPath: '/_next/static/images/',
outputPath: `${isServer ? '../' : ''}static/images/`,
name: '[name]-[hash].[ext]',
},
},
],
});
if (!isServer) {
config.module.rules.push({
test: /\.js$/,
include: [path.resolve(__dirname, 'node_modules', 'react-spring')],
use: [defaultLoaders.babel],
});
}
return config;
},
};