File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { viteSingleFile } from 'vite-plugin-singlefile';
33import path from 'path' ;
44import fs from 'fs' ;
55
6+ const MAX_BUNDLE_SIZE = 1024 * 1024 ; // only increase when absolutely necessary
7+
68const GUIDE_FOR_FRONTEND = `
79<!--
810 This is a single file build of the frontend.
@@ -26,6 +28,13 @@ const BUILD_PLUGINS = [
2628 const outputIndexHtml = path . join ( config . build . outDir , 'index.html' ) ;
2729 const content = fs . readFileSync ( outputIndexHtml , 'utf-8' ) ;
2830
31+ if ( content . length > MAX_BUNDLE_SIZE ) {
32+ throw new Error (
33+ `Bundle size is too large (${ Math . ceil ( content . length / 1024 ) } KB).\n` +
34+ `Please reduce the size of the frontend or increase MAX_BUNDLE_SIZE in vite.config.js.\n` ,
35+ ) ;
36+ }
37+
2938 const targetOutputFile = path . join ( config . build . outDir , '../../public/index.html' ) ;
3039 fs . writeFileSync ( targetOutputFile , GUIDE_FOR_FRONTEND + '\n' + content ) ;
3140 }
You can’t perform that action at this time.
0 commit comments