mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* WIP * WIP * Finish combining JIT and AOT plugins Still lots of clean up that can be done in some of the more complex ones, but at least it's one file per plugin now. * Remove unused import * Fix AOT generation bugs * Move corePlugins/index.js to corePlugins.js * Convert JIT files to ESM * Move tests * Reorder core plugins to match JIT order * Update AOT apply tests * Unify utils * Combine plugin lists to one single source of truth * Finish resolving merge conflicts, fix tests Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
const postcss = require('postcss')
|
|
const tailwind = require('../index.js')
|
|
const sharedState = require('../lib/sharedState.js')
|
|
const configPath = path.resolve(__dirname, './context-reuse.tailwind.config.js')
|
|
|
|
function run(input, config = {}, from = null) {
|
|
from = from || path.resolve(__filename)
|
|
|
|
return postcss(tailwind(config)).process(input, { from })
|
|
}
|
|
|
|
async function runTest() {
|
|
let messages = []
|
|
|
|
let config = {
|
|
darkMode: 'class',
|
|
mode: 'jit',
|
|
purge: [path.resolve(__dirname, './context-reuse.test.html')],
|
|
corePlugins: { preflight: false },
|
|
theme: {},
|
|
plugins: [],
|
|
}
|
|
|
|
let from = path.resolve(__filename)
|
|
|
|
fs.writeFileSync(configPath, `module.exports = ${JSON.stringify(config)};`)
|
|
|
|
let results = [
|
|
await run(`@tailwind utilities;`, configPath, `${from}?id=1`),
|
|
await run(`body { @apply bg-blue-400; }`, configPath, `${from}?id=2`),
|
|
await run(`body { @apply text-red-400; }`, configPath, `${from}?id=3`),
|
|
await run(`body { @apply mb-4; }`, configPath, `${from}?id=4`),
|
|
]
|
|
|
|
results.forEach(() => {
|
|
messages.push({
|
|
activeContexts: sharedState.contextSourcesMap.size,
|
|
})
|
|
})
|
|
|
|
process.stdout.write(JSON.stringify(messages))
|
|
}
|
|
|
|
runTest().finally(() => {
|
|
fs.unlinkSync(configPath)
|
|
})
|