Debian Codegraph @

node/esbuild-sass-plugin/src/index.ts

raw
1 import {OnLoadResult} from "esbuild";
2 import {LoadCacheOptions} from "./cache";
3 import {StringOptions} from "sass";
4 import {sassPlugin} from "./plugin";
5
6 export type Type = 'css' | 'local-css' | 'style' | 'css-text' | 'lit-css' | ((cssText: string, nonce?: string) => string)
7 export type SassPluginOptions = StringOptions<'sync'|'async'> & LoadCacheOptions & {
8
9 /**
10 * Careful: this RegExp has to respect Go limitations!!!
11 */
12 filter?: RegExp
13
14 /**
15 * Function to transform import path. Not just paths by @import
16 * directive, but also paths imported by ts code.
17 */
18 importMapper?: (url: string) => string
19
20 /**
21 * An array of paths that should be looked in to attempt to resolve your @import declarations.
22 * When using `data`, it is recommended that you use this.
23 *
24 * @deprecated please use the new loadPaths option, this is just an alias for it
25 * https://sass-lang.com/documentation/js-api/interfaces/StringOptionsWithoutImporter#loadPaths
26 *
27 * @default []
28 */
29 includePaths?: string[]
30
31 /**
32 * Directory that paths will be relative to.
33 *
34 * @default process.cwd()
35 */
36 basedir?: string
37
38 /**
39 * Type of module wrapper to use
40 *
41 * @default css files will be passed to css loader
42 */
43 type?: Type
44
45 /**
46 * A function which will post process the css file before wrapping it in a module
47 *
48 * @default undefined
49 */
50 transform?: (this: SassPluginOptions, css: string, resolveDir: string, filePath: string) => string | OnLoadResult | Promise<string | OnLoadResult>
51
52 /**
53 *
54 */
55 precompile?: (source: string, path: string, isRoot?: boolean) => string
56
57 /**
58 * Should rewrite leftover css imports starting with ~ so that esbuild can resolve them?
59 */
60 cssImports?: boolean
61
62 /**
63 *
64 */
65 nonce?: string
66
67 /**
68 *
69 */
70 prefer?: 'sass' | 'style' | 'main'
71
72 /**
73 * To enable the sass-embedded compiler
74 */
75 embedded?: boolean
76
77 /**
78 * Use named exports alongside default export.
79 */
80 namedExports?: boolean | "safe" | ((name: string) => string | null | undefined | false)
81 }
82
83 export default sassPlugin
84 export {sassPlugin}
85 export {makeModule, postcssModules} from './utils'