next.config.ts 里有 webpack 配置
This commit is contained in:
1 parent
26372cf6ec
commit
1bb8aadd02
2 files changed
+15
-65
No files matched your search
@@ -0,0 +1,13 @@
|
||||
node_modules
|
||||
.next
|
||||
.git
|
||||
.env
|
||||
logs
|
||||
backups
|
||||
recycle
|
||||
*.md
|
||||
!package.json
|
||||
!package-lock.json
|
||||
nginx
|
||||
systemd
|
||||
scripts
|
||||
@@ -1,88 +1,25 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
devIndicators: false,
|
||||
|
||||
// 启用 standalone 输出模式(用于 Docker 部署)
|
||||
output: "standalone",
|
||||
|
||||
// 实验性功能
|
||||
experimental: {
|
||||
// 启用服务器组件
|
||||
serverActions: {
|
||||
bodySizeLimit: "10mb",
|
||||
},
|
||||
},
|
||||
|
||||
// 图片优化配置
|
||||
images: {
|
||||
// 允许的图片域名
|
||||
remotePatterns: [
|
||||
{
|
||||
protocol: "https",
|
||||
hostname: "**",
|
||||
},
|
||||
],
|
||||
// 图片格式
|
||||
formats: ["image/avif", "image/webp"],
|
||||
},
|
||||
|
||||
// 压缩配置
|
||||
compress: true,
|
||||
|
||||
// 严格模式
|
||||
reactStrictMode: true,
|
||||
|
||||
// 环境变量
|
||||
env: {
|
||||
BLOG_ROOT: process.env.BLOG_ROOT || "",
|
||||
},
|
||||
|
||||
// Webpack 配置
|
||||
webpack: (config, { isServer }) => {
|
||||
// 修复某些依赖的兼容性问题
|
||||
if (!isServer) {
|
||||
config.resolve.fallback = {
|
||||
...config.resolve.fallback,
|
||||
fs: false,
|
||||
net: false,
|
||||
tls: false,
|
||||
};
|
||||
}
|
||||
return config;
|
||||
},
|
||||
|
||||
// 重写规则(可选)
|
||||
async rewrites() {
|
||||
return [
|
||||
// API 代理(如果需要)
|
||||
// {
|
||||
// source: '/api/:path*',
|
||||
// destination: 'http://backend:3000/api/:path*',
|
||||
// },
|
||||
];
|
||||
},
|
||||
|
||||
// 头部配置
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
source: "/(.*)",
|
||||
headers: [
|
||||
{
|
||||
key: "X-Frame-Options",
|
||||
value: "SAMEORIGIN",
|
||||
},
|
||||
{
|
||||
key: "X-Content-Type-Options",
|
||||
value: "nosniff",
|
||||
},
|
||||
{
|
||||
key: "X-XSS-Protection",
|
||||
value: "1; mode=block",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
Reference in new issue
Block a user