Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit d5e5fc3

Browse files
committed
fix(plugin): fix sass loader in deno 1.8 (#169)
1 parent ca1aab7 commit d5e5fc3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

plugins/sass.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
import { Options, renderSync } from 'https://esm.sh/[email protected].5'
1+
import { Options, Result } from 'https://esm.sh/[email protected].8'
22
import type { LoaderPlugin } from '../types.ts'
33

4+
let renderSync: null | ((options: Options) => Result) = null
5+
46
export default (opts?: Options): LoaderPlugin => ({
57
name: 'sass-loader',
68
type: 'loader',
79
test: /\.(sass|scss)$/i,
810
acceptHMR: true,
911
async transform({ content, url }) {
12+
if (!('userAgent' in window.navigator)) {
13+
Object.assign(window.navigator, { userAgent: `Deno/${Deno.version.deno}` })
14+
}
15+
if (renderSync === null) {
16+
const sass = await import('https://esm.sh/[email protected]')
17+
renderSync = sass.renderSync
18+
}
1019
const { css, map } = renderSync({
1120
indentedSyntax: url.endsWith('.sass'),
1221
...opts,

0 commit comments

Comments
 (0)