d1/sqlite支持

This commit is contained in:
mtvpls
2026-01-30 14:27:43 +08:00
parent c4198e0954
commit c86f9cdca7
11 changed files with 2110 additions and 11 deletions
+16 -1
View File
@@ -35,7 +35,7 @@ const nextConfig = {
],
},
webpack(config) {
webpack(config, { isServer }) {
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.('.svg')
@@ -71,6 +71,21 @@ const nextConfig = {
crypto: false,
};
// Exclude better-sqlite3 and D1 modules from client-side bundle
if (!isServer) {
config.externals = config.externals || [];
config.externals.push({
'better-sqlite3': 'commonjs better-sqlite3',
});
config.resolve.alias = {
...config.resolve.alias,
'better-sqlite3': false,
'@/lib/d1.db': false,
'@/lib/d1-adapter': false,
};
}
return config;
},
};