refactor: use _fresh as build cache directory
This commit is contained in:
parent
14bb355c11
commit
d912ea247d
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -9,5 +9,3 @@
|
||||||
_fresh/
|
_fresh/
|
||||||
# npm dependencies
|
# npm dependencies
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
.cache/
|
|
8
build.ts
8
build.ts
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue