forked from dair-ai/Prompt-Engineering-Guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
50 lines (44 loc) · 1.34 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
48
49
50
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
latex: true
})
module.exports = withNextra({
i18n: {
// locales: ['en', 'zh', 'jp', 'pt', 'tr', 'es', 'it', 'fr', 'kr', 'ca', 'fi', 'ru', 'de', 'ar'],
locales: ['en', 'zh'],
defaultLocale: 'zh',
},
compress: true, // 启用压缩
images: {
// domains: ['example.com'], // 替换为你的图片域名
// deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
// imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
formats: ['image/avif', 'image/webp'],
},
webpack(config, { dev, isServer }) {
const allowedSvgRegex = /components\/icons\/.+\.svg$/
const fileLoaderRule = config.module.rules.find(rule =>
rule.test?.test?.('.svg')
)
fileLoaderRule.exclude = allowedSvgRegex
config.module.rules.push({
test: allowedSvgRegex,
use: ['@svgr/webpack']
})
if (!dev && !isServer) {
// 开启 JavaScript 压缩
config.optimization.minimize = true;
// 添加 CSS 压缩插件
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
config.plugins.push(
new OptimizeCSSAssetsPlugin({})
);
}
return config;
},
// 移除仅在开发时需要的配置
devIndicators: {
buildActivity: false,
},
});