mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-25 09:47:37 +00:00
refactor: update node polyfills and add buffer-polyfill plugin
Modify the node polyfills configuration to include additional modules and add a new buffer-polyfill plugin to handle Buffer imports in env.mjs files. This change ensures compatibility with required Node.js modules in the Vite environment.
This commit is contained in:
parent
c63732d2f4
commit
cdbf9ba730
@ -96,8 +96,28 @@ export default defineConfig((config) => {
|
|||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
nodePolyfills({
|
nodePolyfills({
|
||||||
include: ['path', 'buffer', 'process'],
|
include: ['buffer', 'process', 'util', 'stream'],
|
||||||
|
globals: {
|
||||||
|
Buffer: true,
|
||||||
|
process: true,
|
||||||
|
global: true,
|
||||||
|
},
|
||||||
|
protocolImports: true,
|
||||||
|
exclude: ['child_process', 'fs', 'path'],
|
||||||
}),
|
}),
|
||||||
|
{
|
||||||
|
name: 'buffer-polyfill',
|
||||||
|
transform(code, id) {
|
||||||
|
if (id.includes('env.mjs')) {
|
||||||
|
return {
|
||||||
|
code: `import { Buffer } from 'buffer';\n${code}`,
|
||||||
|
map: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
},
|
||||||
config.mode !== 'test' && remixCloudflareDevProxy(),
|
config.mode !== 'test' && remixCloudflareDevProxy(),
|
||||||
remixVitePlugin({
|
remixVitePlugin({
|
||||||
future: {
|
future: {
|
||||||
|
Loading…
Reference in New Issue
Block a user