-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnext.config.js
More file actions
69 lines (66 loc) · 1.96 KB
/
Copy pathnext.config.js
File metadata and controls
69 lines (66 loc) · 1.96 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
68
69
const { withContentlayer } = require("next-contentlayer2");
// const NextOSSPlugin = require("next-oss-webpack-plugin");
// const isProd = process.env.NODE_ENV === "production";
/** @type {import('next').NextConfig} */
const nextConfig = {
// 配置 CDN 地址
// assetPrefix: isProd ? "https://cdn.example.com/offernow/" : "",
swcMinify: true,
output: "standalone",
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
// Next.js 开发模式默认会开启 React Strict Mode,会渲染2次,我们不需要
reactStrictMode: false,
// build 阶段禁止 ts 类型检查
typescript: {
ignoreBuildErrors: true,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "chev.contrails.space",
port: "12650",
pathname: "/images/**",
},
{
protocol: "https",
hostname: "oss1.aistar.cool",
pathname: "/**/**",
},
{
protocol: "https",
hostname: ".*",
port: "",
pathname: "*/**",
},
{
protocol: "http",
hostname: "localhost",
},
],
},
webpack: (config, { buildId }) => {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});
// if (isProd && buildId) {
// config.plugins.push(
// new NextOSSPlugin({
// region: "oss-cn-hangzhou", // bucket所在区域
// accessKeyId: process.env.R2_ACCESSKEYI,
// accessKeySecret: process.env.R2_SECRET_ACCESSKEY,
// bucket: process.env.R2_BUCKET,
// filter: (assert) => /\.js$/.test(assert),
// assetPrefix: `${assetPrefix}/_next/`, // 上传资源前缀
// customizedOssPaths: [
// // 替换为 /:buildId/page/xxx.js ,使能正常访问
// { pattern: /bundles\/pages/g, replace: `${buildId}/page` },
// ],
// })
// );
// }
return config;
},
};
module.exports = withContentlayer(nextConfig);