MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / unocss_plugin

Function unocss_plugin

packages/frontend/build.ts:24–58  ·  view source on GitHub ↗
(output_file: string)

Source from the content-addressed store, hash-verified

22const pkg_filename = path.join(dirname, 'package.json')
23
24function unocss_plugin(output_file: string): esb.Plugin {
25 return {
26 name: 'unocss',
27 setup(build) {
28
29 let filenames_set = new Set<string>()
30
31 build.onStart(() => {
32 filenames_set.clear()
33 })
34
35 build.onLoad({filter: /\.tsx$/}, args => {
36 filenames_set.add(args.path)
37 return null
38 })
39
40 // Generate CSS from all processed files
41 build.onEnd(async () => {
42
43 let uno = await unocss.createGenerator(uno_config)
44
45 let filenames = Array.from(filenames_set)
46 let files = await Promise.all(filenames.map(
47 filename => fsp.readFile(filename, 'utf-8')
48 ))
49
50 let res = await uno.generate(files.join('\n'))
51
52 await fsp.writeFile(output_file, res.css)
53
54 return null
55 })
56 }
57 }
58}
59
60export default () => {
61

Callers 1

build.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…