-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
40 lines (37 loc) · 961 Bytes
/
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
const webpack = require('webpack');
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
domains: ['localhost'], // 添加你需要的图片域名
remotePatterns: [
{
protocol: 'https',
hostname: '**',
},
],
},
reactStrictMode: true,
swcMinify: true,
webpack: (config, { isServer }) => {
if (!isServer) {
// 客户端打包配置
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
util: require.resolve('util/'),
stream: require.resolve('stream-browserify'),
zlib: require.resolve('browserify-zlib'),
assert: require.resolve('assert/'),
buffer: require.resolve('buffer/'),
};
// 注入 Buffer 全局变量
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
})
);
}
return config;
},
}
module.exports = nextConfig