Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(frontend): use Svelte bundle strategy single #4804

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const config = {

version: {
name: version
},

output: {
bundleStrategy: 'single'
}
}
};
Expand Down
27 changes: 1 addition & 26 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import inject from '@rollup/plugin-inject';
import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { basename, dirname, resolve } from 'node:path';
import { basename, resolve } from 'node:path';
import { defineConfig, loadEnv, type UserConfig } from 'vite';
import { CSS_CONFIG_OPTIONS, defineViteReplacements, readCanisterIds } from './vite.utils';

Expand All @@ -24,31 +24,6 @@ const config: UserConfig = {
build: {
target: 'es2020',
rollupOptions: {
output: {
manualChunks: (id) => {
const folder = dirname(id);

const lazy = ['@dfinity/nns', '@dfinity/nns-proto', 'html5-qrcode', 'qr-creator'];

if (
['@sveltejs', 'svelte', '@dfinity/gix-components', ...lazy].find((lib) =>
folder.includes(lib)
) === undefined &&
folder.includes('node_modules')
) {
return 'vendor';
}

if (
lazy.find((lib) => folder.includes(lib)) !== undefined &&
folder.includes('node_modules')
) {
return 'lazy';
}

return 'index';
}
},
// Polyfill Buffer for production build
plugins: [
inject({
Expand Down
Loading