Skip to content

Commit eb0f574

Browse files
committed
feat: add css-loader inline style tag
1 parent 869b690 commit eb0f574

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

packages/unplugin-tailwindcss-mangle/src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@ export const unplugin = createUnplugin((options: Options | undefined = {}, meta)
103103
},
104104
(assets) => {
105105
// nextjs webpack build multiple times
106-
// server / manifest / client
107-
// const resolvePath = require.resolve('tailwindcss')
108-
// console.log(resolvePath)
109-
// console.log(compiler.outputPath)
106+
// server -> manifest -> client
107+
110108
const runtimeSet = getCachedClassSet()
111109
const groupedEntries = getGroupedEntries(Object.entries(assets))
112110
// cache result
@@ -134,8 +132,6 @@ export const unplugin = createUnplugin((options: Options | undefined = {}, meta)
134132
return
135133
}
136134

137-
// fs.writeFileSync('./tw-class-set.json', JSON.stringify(Array.from(runtimeSet)), 'utf-8')
138-
139135
if (groupedEntries.html.length) {
140136
for (let i = 0; i < groupedEntries.html.length; i++) {
141137
const [file, asset] = groupedEntries.html[i]

packages/unplugin-tailwindcss-mangle/src/options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Options, ClassSetOutputOptions, ClassMapOutputOptions } from './types'
2-
import { getClassCacheSet } from 'tailwindcss-patch'
2+
import { TailwindcssPatcher } from 'tailwindcss-patch'
33
import ClassGenerator from './classGenerator'
44
import { createGlobMatcher, isMangleClass, cacheDump } from './utils'
55

@@ -12,7 +12,7 @@ export function getOptions(options: Options | undefined = {}) {
1212
}
1313

1414
let classSet: Set<string>
15-
15+
const twPatcher = new TailwindcssPatcher()
1616
const classSetOutputOptions: ClassSetOutputOptions = {
1717
filename: 'classSet.json',
1818
type: 'partial'
@@ -32,7 +32,7 @@ export function getOptions(options: Options | undefined = {}) {
3232
// let cached: boolean
3333
const classGenerator = new ClassGenerator(options.classGenerator)
3434
function getCachedClassSet() {
35-
const set = getClassCacheSet()
35+
const set = twPatcher.getClassSet()
3636
const isOutput = set.size && options.classSetOutput
3737
if (isOutput && classSetOutputOptions.type === 'all') {
3838
cacheDump(classSetOutputOptions.filename, set, classSetOutputOptions.dir)

packages/unplugin-tailwindcss-mangle/test/fixtures/css-loader.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)