Skip to main content
Module

x/aleph/plugins/sass.ts

The Full-stack Framework in Deno.
Go to Latest
File
import { Options, renderSync } from 'https://esm.sh/sass@1.32.5'import type { LoaderPlugin } from '../types.ts'
const pluginFactory = (opts: Options = {}): LoaderPlugin => ({ type: 'loader', test: /.(sass|scss)$/, acceptHMR: true, transform(content: Uint8Array, path: string) { const ret = renderSync({ indentedSyntax: path.endsWith('.sass'), ...opts, file: path, data: (new TextDecoder).decode(content), sourceMap: true }) return { code: (new TextDecoder).decode(ret.css), map: ret.map ? (new TextDecoder).decode(ret.map) : undefined, format: 'css', } }})
// make the `pluginFactory` function as a pluginconst defaultPlugin = pluginFactory()pluginFactory.type = defaultPlugin.typepluginFactory.test = defaultPlugin.testpluginFactory.acceptHMR = defaultPlugin.acceptHMRpluginFactory.transform = defaultPlugin.transform
export default pluginFactory