-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathnext.config.js
More file actions
67 lines (64 loc) · 1.65 KB
/
next.config.js
File metadata and controls
67 lines (64 loc) · 1.65 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
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
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const withPlugins = require('next-compose-plugins');
const withLess = require('next-with-less');
const withPWA = require('next-pwa');
const { config } = require('@fecommunity/reactpress-toolkit');
const antdVariablesFilePath = path.resolve(__dirname, './antd-custom.less');
const getServerApiUrl = () => {
if (config.SERVER_URL) {
return `${config.SERVER_SITE_URL}/api`;
} else {
return config.SERVER_API_URL || `${process.env.SERVER_SITE_URL}/api` || 'http://localhost:3002/api';
}
};
/** @type {import('next').NextConfig} */
const nextConfig = {
assetPrefix: config.CLIENT_ASSET_PREFIX || '/',
i18n: {
locales: config.locales && config.locales.length > 0 ? config.locales : ['zh', 'en'],
defaultLocale: config.defaultLocale || 'zh',
},
env: {
SERVER_API_URL: getServerApiUrl(),
GITHUB_CLIENT_ID: config.GITHUB_CLIENT_ID,
},
webpack: (config, { dev, isServer }) => {
config.resolve.plugins.push(new TsconfigPathsPlugin());
return config;
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
compiler: {
removeConsole: {
exclude: ['error'],
},
},
};
module.exports = withPlugins(
[
[
withPWA,
{
pwa: {
disable: process.env.NODE_ENV !== 'production',
dest: '.next',
sw: 'service-worker.js',
},
},
],
[
withLess,
{
lessLoaderOptions: {
additionalData: (content) => `${content}\n\n@import '${antdVariablesFilePath}';`,
},
},
],
],
nextConfig
);