forked from RSSNext/Folo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcssAsPlugin.js
More file actions
24 lines (22 loc) · 774 Bytes
/
cssAsPlugin.js
File metadata and controls
24 lines (22 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// https://github.com/tailwindlabs/tailwindcss-intellisense/issues/227#issuecomment-1462034856
// cssAsPlugin.js
const postcss = require("postcss")
const postcssJs = require("postcss-js")
const { readFileSync } = require("node:fs")
require.extensions[".css"] = function (module, filename) {
const cssAsPlugin = ({ addBase, addComponents, addUtilities }) => {
const css = readFileSync(filename, "utf8")
const root = postcss.parse(css)
const jss = postcssJs.objectify(root)
if ("@layer base" in jss) {
addBase(jss["@layer base"])
}
if ("@layer components" in jss) {
addComponents(jss["@layer components"])
}
if ("@layer utilities" in jss) {
addUtilities(jss["@layer utilities"])
}
}
module.exports = cssAsPlugin
}