Skip to content

Commit 3e045ef

Browse files
committed
Add check for Svelte imports
1 parent 44f238a commit 3e045ef

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

_extensions/sverto/rollup.config.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ const production = !process.env.ROLLUP_WATCH;
3434

3535
// get quarto project output directory and list of inputs
3636
// 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')
37+
const quartoOutDir = fs.readFileSync('.sverto/.sverto-outdir', 'utf8');
38+
39+
let svelteConfig = {};
40+
const svelteImportListPath = '.sverto/.sverto-imports';
41+
42+
// skip svelte compilation if there's nothing to compile
43+
if (!fs.existsSync(svelteImportListPath)) {
44+
console.log("ℹ No Svelte imports to process; skipping compilation");
45+
process.exit();
46+
}
47+
48+
// get the list of unique imports to compile
49+
const svelteFiles = fs.readFileSync(svelteImportListPath, 'utf8')
3950
.split("\n")
4051
.filter(d => d !== "");
41-
42-
// remove duplicate svelte components (being used by several qmds)
4352
const uniqueSvelteFiles = [... new Set(svelteFiles)]
4453

4554
// we export an array of rollup configs: one for each input svelte file

0 commit comments

Comments
 (0)