generated from ciampo/_nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
47 lines (40 loc) · 1.14 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
// const fs = require('fs');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
require('dotenv').config();
// const routesConfig = require('./routes-config.js');
// const ROOT_FOLDER = process.cwd();
// const DATA_FOLDER = path.join(ROOT_FOLDER, 'data');
const nextConfig = {
webpack(config, options) {
// From preact netx.js example
if (options.isServer) {
config.externals = ['react', 'react-dom', ...config.externals];
}
// From preact netx.js example
config.resolve.alias = {
...config.resolve.alias,
react: 'preact/compat',
react$: 'preact/compat',
'react-dom': 'preact/compat',
'react-dom$': 'preact/compat',
};
config.module.rules.push({
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
fix: true,
},
});
return config;
},
env: {
GA: process.env.GA,
CANONICAL_URL: process.env.CANONICAL_URL,
},
};
module.exports = withBundleAnalyzer(nextConfig);