mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-21 21:44:40 +03:00
chore: fix and optimize build
especially for vercel limited RAM (8GB)
This commit is contained in:
1 parent
6f1b17fc66
commit
d4447dfb2e
1 file changed
+21
-17
+21
-17
@@ -116,6 +116,7 @@ export default defineConfig({
|
|||||||
'@babel/core': fileURLToPath(new URL('./src/_empty.ts', import.meta.url)),
|
'@babel/core': fileURLToPath(new URL('./src/_empty.ts', import.meta.url)),
|
||||||
'isolated-vm': fileURLToPath(new URL('./src/_empty.ts', import.meta.url)),
|
'isolated-vm': fileURLToPath(new URL('./src/_empty.ts', import.meta.url)),
|
||||||
'onnxruntime-node': fileURLToPath(new URL('./src/_empty.ts', import.meta.url)),
|
'onnxruntime-node': fileURLToPath(new URL('./src/_empty.ts', import.meta.url)),
|
||||||
|
'webcrypto-liner-shim': !process.env.VERCEL ? 'webcrypto-liner-shim' : fileURLToPath(new URL('./src/_empty.ts', import.meta.url)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
@@ -130,31 +131,34 @@ export default defineConfig({
|
|||||||
minify: !process.env.VERCEL,
|
minify: !process.env.VERCEL,
|
||||||
reportCompressedSize: !process.env.VERCEL,
|
reportCompressedSize: !process.env.VERCEL,
|
||||||
// cssMinify: false,
|
// cssMinify: false,
|
||||||
modulePreload: false,
|
// modulePreload: false,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: ['regex', './out/isolated_vm', 'isolated-vm', 'onnxruntime-node'],
|
external: ['regex', './out/isolated_vm', 'isolated-vm', 'onnxruntime-node',
|
||||||
|
...(process.env.VERCEL ? ['webcrypto-liner-shim'] : [])
|
||||||
|
],
|
||||||
output: {
|
output: {
|
||||||
format: 'es',
|
format: 'es',
|
||||||
manualChunks: (id) => {
|
// manualChunks: (id) => {
|
||||||
// if (id.includes('monaco-editor')) return 'monaco-editor';
|
// // if (id.includes('monaco-editor')) return 'monaco-editor';
|
||||||
if (id.includes('tesseract.js')) return 'tesseract.js';
|
// if (id.includes('tesseract.js')) return 'tesseract.js';
|
||||||
if (id.includes('pdfjs')) return 'pdfjs';
|
// if (id.includes('pdfjs')) return 'pdfjs';
|
||||||
if (id.includes('unicode')) return 'unicode';
|
// if (id.includes('unicode')) return 'unicode';
|
||||||
// if (id.includes('transformers')) return 'transformers';
|
// // if (id.includes('transformers')) return 'transformers';
|
||||||
// if (id.includes("node_modules")) {
|
// // if (id.includes("node_modules")) {
|
||||||
// return "vendor";
|
// // return "vendor";
|
||||||
// }
|
// // }
|
||||||
},
|
// },
|
||||||
sourcemapIgnoreList: (relativeSourcePath) => {
|
// sourcemapIgnoreList: (relativeSourcePath) => {
|
||||||
const normalizedPath = path.normalize(relativeSourcePath);
|
// const normalizedPath = path.normalize(relativeSourcePath);
|
||||||
return normalizedPath.includes("node_modules");
|
// return normalizedPath.includes("node_modules");
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
cache: false,
|
cache: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
include: ['isolated-vm', 'pdfjs-dist', 'onnxruntime-node'], // optionally specify dependency name
|
include: ['isolated-vm', 'pdfjs-dist', 'onnxruntime-node',
|
||||||
|
...(process.env.VERCEL ? ['webcrypto-liner-shim'] : [])], // optionally specify dependency name
|
||||||
esbuildOptions: {
|
esbuildOptions: {
|
||||||
supported: {
|
supported: {
|
||||||
'top-level-await': true,
|
'top-level-await': true,
|
||||||
|
|||||||
Reference in new issue
Block a user