Skip to content

Commit 1e0d967

Browse files
committed
add css from playground
1 parent 792e900 commit 1e0d967

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

apps/svelte.dev/scripts/get_svelte_template.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ try {
4545
let data = bytes.compare(Buffer.from(string)) === 0 ? string : [...bytes];
4646

4747
if (path.endsWith('routes/+page.svelte')) {
48-
data = `<script>\nimport App from './App.svelte';\n</script>\n\n<App />\n`;
48+
data = `<script>\n\timport '../app.css';\n\timport App from './App.svelte';\n</script>\n\n<App />\n`;
4949
}
5050

5151
files.push({ path: path.slice(output_dir.length + 1), data });
@@ -60,6 +60,25 @@ try {
6060
'export const ssr = false;\n'
6161
});
6262

63+
// add CSS styles from playground to the project
64+
const html = readFileSync(
65+
join(output_dir, '../../../../packages/repl/src/lib/Output/srcdoc/index.html'),
66+
{ encoding: 'utf-8' }
67+
);
68+
const css = html
69+
.slice(html.indexOf('<style>') + 7, html.indexOf('</style>'))
70+
.split('\n')
71+
.map((line) =>
72+
// remove leading \t
73+
line.slice(3)
74+
)
75+
.join('\n')
76+
.trimStart();
77+
files.push({
78+
path: 'src/app.css',
79+
data: css
80+
});
81+
6382
writeFileSync(output_file, JSON.stringify(files));
6483

6584
// remove output dir afterwards to prevent it messing with Vite watcher

0 commit comments

Comments
 (0)