refactor: use _fresh as build cache directory

This commit is contained in:
Julien Oculi 2024-01-14 20:54:49 +01:00
parent 14bb355c11
commit d912ea247d
2 changed files with 4 additions and 6 deletions

2
.gitignore vendored
View file

@ -9,5 +9,3 @@
_fresh/ _fresh/
# npm dependencies # npm dependencies
node_modules/ node_modules/
.cache/

View file

@ -3,6 +3,7 @@ import { ensureDir } from '$std/fs/mod.ts'
import { parse, resolve } from '$std/path/mod.ts' import { parse, resolve } from '$std/path/mod.ts'
console.log('building styles starts') console.log('building styles starts')
await ensureDir('_fresh')
try { try {
//prevent Deno from exiting before bundle //prevent Deno from exiting before bundle
@ -30,8 +31,7 @@ try {
const response = await fetch(specifier) const response = await fetch(specifier)
const file = await response.text() const file = await response.text()
await ensureDir('.cache') const filename = `_fresh/${crypto.randomUUID()}`
const filename = `.cache/${crypto.randomUUID()}.css`
await Deno.writeTextFile(filename, file) await Deno.writeTextFile(filename, file)
cssImports.set(specifier, filename) cssImports.set(specifier, filename)
return filename return filename
@ -40,11 +40,11 @@ try {
}) })
await Deno.writeTextFile( await Deno.writeTextFile(
'./static/styles.css', './_fresh/styles.css',
new TextDecoder().decode(code), new TextDecoder().decode(code),
) )
await Deno.writeTextFile( await Deno.writeTextFile(
'./static/styles.map.css', './_fresh/styles.map.css',
new TextDecoder().decode(map!), new TextDecoder().decode(map!),
) )
} catch (error) { } catch (error) {