feat(editor): Remove manual chunking from vite (no-changelog) (#11206)

This commit is contained in:
Alex Grozav 2024-10-10 16:34:08 +03:00 committed by GitHub
parent 401275884e
commit eaf933049e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,41 +3,11 @@ import { resolve } from 'path';
import { defineConfig, mergeConfig } from 'vite';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import packageJSON from './package.json';
import { vitestConfig } from '../design-system/vite.config.mts';
import icons from 'unplugin-icons/vite';
import iconsResolver from 'unplugin-icons/resolver';
import components from 'unplugin-vue-components/vite';
const vendorChunks = ['vue', 'vue-router'];
const n8nChunks = ['n8n-workflow', 'n8n-design-system', '@n8n/chat'];
const ignoreChunks = [
'@fontsource/open-sans',
'@vueuse/components',
// TODO: remove this. It's currently required by xml2js in NodeErrors
'stream-browserify',
'vue-markdown-render',
];
const isScopedPackageToIgnore = (str: string) => /@codemirror\//.test(str);
function renderChunks() {
const { dependencies } = packageJSON;
const chunks: Record<string, string[]> = {};
Object.keys(dependencies).forEach((key) => {
if ([...vendorChunks, ...n8nChunks, ...ignoreChunks].includes(key)) {
return;
}
if (isScopedPackageToIgnore(key)) return;
chunks[key] = [key];
});
return chunks;
}
const publicPath = process.env.VUE_APP_PUBLIC_PATH || '/';
const { NODE_ENV } = process.env;
@ -124,19 +94,8 @@ export default mergeConfig(
},
},
build: {
assetsInlineLimit: 0,
minify: !!release,
sourcemap: !!release,
rollupOptions: {
treeshake: !!release,
output: {
manualChunks: {
vendor: vendorChunks,
n8n: n8nChunks,
...renderChunks(),
},
},
},
},
}),
vitestConfig,