11import svelte from 'rollup-plugin-svelte' ;
22import commonjs from '@rollup/plugin-commonjs' ;
33import resolve from '@rollup/plugin-node-resolve' ;
4- // import livereload from 'rollup-plugin-livereload';
54import { terser } from 'rollup-plugin-terser' ;
65import css from 'rollup-plugin-css-only' ;
76
@@ -11,35 +10,21 @@ const path = require('node:path');
1110// this is false when we run rollup with -w/--watch (never presently)
1211const production = ! process . env . ROLLUP_WATCH ;
1312
14- // function serve() {
15- // let server;
16-
17- // function toExit() {
18- // if (server) server.kill(0);
19- // }
20-
21- // return {
22- // writeBundle() {
23- // if (server) return;
24- // server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
25- // stdio: ['ignore', 'inherit', 'inherit'],
26- // shell: true
27- // });
28-
29- // process.on('SIGTERM', toExit);
30- // process.on('exit', toExit);
31- // }
32- // };
33- // }
34-
3513// get quarto project output directory and list of inputs
36- // const quartoOutDir = process.env.QUARTO_PROJECT_OUTPUT_DIR;
37- const quartoOutDir = fs . readFileSync ( '.sverto/.sverto-outdir' , 'utf8' )
38- const svelteFiles = fs . readFileSync ( '.sverto/.sverto-imports' , 'utf8' )
14+ const quartoOutDir = fs . readFileSync ( '.sverto/.sverto-outdir' , 'utf8' ) ;
15+
16+ const svelteImportListPath = '.sverto/.sverto-imports' ;
17+
18+ // skip svelte compilation if there's nothing to compile
19+ if ( ! fs . existsSync ( svelteImportListPath ) ) {
20+ console . log ( "ℹ No Svelte imports to process; skipping compilation" ) ;
21+ process . exit ( ) ;
22+ }
23+
24+ // get the list of unique imports to compile
25+ const svelteFiles = fs . readFileSync ( svelteImportListPath , 'utf8' )
3926 . split ( "\n" )
4027 . filter ( d => d !== "" ) ;
41-
42- // remove duplicate svelte components (being used by several qmds)
4328const uniqueSvelteFiles = [ ... new Set ( svelteFiles ) ]
4429
4530// we export an array of rollup configs: one for each input svelte file
@@ -71,11 +56,6 @@ export default uniqueSvelteFiles.map(
7156 dedupe : [ "svelte" ]
7257 } ) ,
7358 commonjs ( ) ,
74- // !production && serve(),
75- // !production && livereload("public"),
7659 production && terser ( )
77- ] //,
78- // watch: {
79- // clearScreen: false
80- // }
60+ ]
8161 } ) ) ;
0 commit comments