This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
63 lines (52 loc) · 1.68 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
62
63
require('dotenv').config();
const path = require('path');
const DotEnv = require('dotenv-webpack');
const withPlugins = require('next-compose-plugins');
const withSass = require('@zeit/next-sass');
const withCss = require('@zeit/next-css');
const withFonts = require('next-fonts');
const webpackConfig = require('./webpack.config');
// https://github.com/zeit/next.js/issues/5509#issuecomment-432456576
const generateLocalePath = defaultPathMap => {
const pathMap = {};
const allLanguage = ['en', 'cn'];
Object.entries(defaultPathMap).forEach(([key, value]) => {
pathMap[key] = value;
allLanguage.forEach(language => {
pathMap[`/${language}${key}`] = {...value, query: {language}};
});
});
};
const nextConfig = {
poweredByHeader: false,
exportTrailingSlash: false,
assetPrefix: process.env.ROUTE_PREFIX_PATH || '',
publicRuntimeConfig: {
assetPrefix: process.env.ROUTE_PREFIX_PATH || '',
},
enableSvg: true,
webpack: config => {
config.node = {
fs: 'empty',
};
config.plugins = [
...config.plugins,
// Read the .env file
new DotEnv({
path: path.join(__dirname, '.env'),
systemvars: true,
}),
];
config.module.rules = [
...config.module.rules,
// setting your custom rules...
];
// 附加 webpack.config 的 alias 別名路徑設定
config.resolve.alias = Object.assign(config.resolve.alias, webpackConfig.resolve.alias);
return config;
},
};
module.exports = withPlugins(
[withCss, withSass, withFonts],
nextConfig
);