next-windfonts/next.config.mjs
bo.yu 9f707f3fbe docs: 添加GPL-3.0许可证及相关文档
- 在package.json中添加GPL-3.0许可证声明
- 创建LICENSE文件包含完整GPL-3.0许可证文本
- 更新README.md中的许可证章节,详细说明GPL-3.0要点
- 在所有主要源代码文件头部添加GPL-3.0版权声明
- 新增CONTRIBUTING.md贡献指南文档
2025-09-08 15:22:56 +08:00

98 lines
2.8 KiB
JavaScript

/*
* Next WindFonts - 现代化字体管理和展示平台
* Copyright (C) 2025 WindFonts Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import withPlugins from 'next-compose-plugins';
import bundleAnalyzer from '@next/bundle-analyzer';
import { withContentlayer } from 'next-contentlayer2';
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.NEXT_PUBLIC_ANALYZE === 'true',
});
const nextConfig = {
reactStrictMode: true,
// 你的其他配置项
webpack: (config, { isServer }) => {
if (isServer) {
// Force webpack to include pg and related packages
config.externals = config.externals.filter(external => {
if (typeof external === 'string') {
return !['pg', 'pg-hstore', 'pg-native'].includes(external)
}
if (typeof external === 'function') {
return (context, request, callback) => {
if (['pg', 'pg-hstore', 'pg-native'].includes(request)) {
return callback()
}
return external(context, request, callback)
}
}
return true
})
// Externalize native modules that cause issues
config.externals.push(
'@napi-rs/woff-build',
'@napi-rs/woff-build-wasm32-wasi',
'wf-cn-font-split'
)
}
// Handle .node files
config.module.rules.push({
test: /\.node$/,
use: 'node-loader',
})
// Add fallbacks for Node.js modules
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
crypto: false,
}
return config;
},
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx', 'mjs'],
};
const plugins = [
[
withBundleAnalyzer,
{
reactStrictMode: false,
eslint: {
ignoreDuringBuilds: true,
},
output: 'standalone',
experimental: {
optimizePackageImports: ['@mantine/core', '@mantine/hooks'],
},
},
],
[
withContentlayer,
{
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx', 'mjs'],
// Optionally, add any other Next.js config below
},
],
];
export default withPlugins(plugins, nextConfig);