forked from wednesday-solutions/nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
45 lines (41 loc) · 1.31 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
const withImages = require('next-images');
const path = require('path');
const withTM = require('next-transpile-modules')([
'@formatjs/intl-relativetimeformat',
'@formatjs/intl-utils',
'react-intl',
'intl-format-cache',
'intl-messageformat-parser',
'intl-messageformat'
]);
const constructAlias = (config) => {
return {
'@app': path.resolve(__dirname, './app'),
'@components': path.resolve(__dirname, './app/components'),
'@themes': path.resolve(__dirname, './app/themes'),
'@utils': path.resolve(__dirname, './app/utils'),
'@images': path.resolve(__dirname, './app/images'),
'@store': path.resolve(__dirname, './app/store'),
'@services': path.resolve(__dirname, './app/services'),
...config.resolve.alias
};
};
module.exports = withTM(
withImages({
assetPrefix: process.env.BASE_PATH || '',
basePath: process.env.BASE_PATH || '',
trailingSlash: true,
webpack(config, options) {
config.resolve.alias = constructAlias(config);
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
if (entries['main.js'] && !entries['main.js'].includes('./polyfills.js')) {
entries['main.js'].unshift('./polyfills.js');
}
return entries;
};
return config;
}
})
);