forked from serverless-plus/serverless-v2ex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
48 lines (42 loc) · 1.04 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
require('dotenv').config();
const path = require('path');
function moduleDir(m) {
return path.dirname(require.resolve(`${m}/package.json`));
}
const isProd = process.env.NODE_ENV === 'production';
// if not use CDN, change to your cos access domain
const STATIC_URL = 'https://static.v2ex.yuga.chat';
module.exports = {
env: {
STATIC_URL: isProd
? STATIC_URL
: `http://localhost:${parseInt(process.env.PORT, 10) || 8000}`,
},
assetPrefix: isProd ? STATIC_URL : '',
webpack: (config, { dev }) => {
config.resolve.extensions = [
'.web.js',
'.js',
'.jsx',
'.ts',
'.tsx',
'.json',
];
config.module.rules.push(
{
test: /\.(svg)$/i,
loader: 'emit-file-loader',
options: {
name: 'dist/[path][name].[ext]',
},
include: [moduleDir('antd-mobile'), __dirname],
},
{
test: /\.(svg)$/i,
loader: 'svg-sprite-loader',
include: [moduleDir('antd-mobile'), __dirname],
},
);
return config;
},
};