修复tiktoken计算插件打包错误

This commit is contained in:
sijinhui
2023-12-27 22:17:12 +08:00
parent 4383fbc1ef
commit eec5418e14
3 changed files with 17 additions and 2 deletions

View File

@@ -9,6 +9,9 @@ console.log("[Next] build with chunk: ", disableChunk);
/** @type {import('next').NextConfig} */
// const isProd = process.env.NODE_ENV === 'production'
// 为了修复tiktoken的插件问题
import CopyPlugin from "copy-webpack-plugin";
const nextConfig = {
webpack(config) {
config.module.rules.push({
@@ -21,6 +24,17 @@ const nextConfig = {
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
)
}
config.plugins.push(
new CopyPlugin({
patterns: [
{
from: ".//node_modules/tiktoken/tiktoken_bg.wasm",
to: "tiktoken_bg.wasm",
toType: "file",
}
]
})
)
config.optimization.minimize = true
config.optimization.splitChunks = {