Detect changes to the config file and plugins for the CLI
This commit is contained in:
parent
3a7feb7930
commit
d607f0a40e
8 changed files with 238 additions and 19 deletions
|
|
@ -83,3 +83,109 @@ test(
|
|||
])
|
||||
},
|
||||
)
|
||||
|
||||
test(
|
||||
'Config files (CJS, watch mode)',
|
||||
{
|
||||
fs: {
|
||||
'package.json': json`
|
||||
{
|
||||
"dependencies": {
|
||||
"tailwindcss": "workspace:^",
|
||||
"@tailwindcss/cli": "workspace:^"
|
||||
}
|
||||
}
|
||||
`,
|
||||
'index.html': html`
|
||||
<div class="text-primary"></div>
|
||||
`,
|
||||
'tailwind.config.js': js`
|
||||
const myColor = require('./my-color')
|
||||
module.exports = {
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
primary: myColor,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
`,
|
||||
'my-color.js': js`module.exports = 'blue'`,
|
||||
'src/index.css': css`
|
||||
@import 'tailwindcss';
|
||||
@config '../tailwind.config.js';
|
||||
`,
|
||||
},
|
||||
},
|
||||
async ({ fs, spawn }) => {
|
||||
await spawn('pnpm tailwindcss --input src/index.css --output dist/out.css --watch')
|
||||
|
||||
await fs.expectFileToContain('dist/out.css', [
|
||||
//
|
||||
candidate`text-primary`,
|
||||
'color: blue',
|
||||
])
|
||||
|
||||
await fs.write('my-color.js', js`module.exports = 'red'`)
|
||||
|
||||
await fs.expectFileToContain('dist/out.css', [
|
||||
//
|
||||
candidate`text-primary`,
|
||||
'color: red',
|
||||
])
|
||||
},
|
||||
)
|
||||
|
||||
test(
|
||||
'Config files (MJS, watch mode)',
|
||||
{
|
||||
fs: {
|
||||
'package.json': json`
|
||||
{
|
||||
"dependencies": {
|
||||
"tailwindcss": "workspace:^",
|
||||
"@tailwindcss/cli": "workspace:^"
|
||||
}
|
||||
}
|
||||
`,
|
||||
'index.html': html`
|
||||
<div class="text-primary"></div>
|
||||
`,
|
||||
'tailwind.config.mjs': js`
|
||||
import myColor from './my-color.mjs'
|
||||
export default {
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
primary: myColor,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
`,
|
||||
'my-color.mjs': js`export default 'blue'`,
|
||||
'src/index.css': css`
|
||||
@import 'tailwindcss';
|
||||
@config '../tailwind.config.mjs';
|
||||
`,
|
||||
},
|
||||
},
|
||||
async ({ fs, spawn }) => {
|
||||
await spawn('pnpm tailwindcss --input src/index.css --output dist/out.css --watch')
|
||||
|
||||
await fs.expectFileToContain('dist/out.css', [
|
||||
//
|
||||
candidate`text-primary`,
|
||||
'color: blue',
|
||||
])
|
||||
|
||||
await fs.write('my-color.mjs', js`export default 'red'`)
|
||||
|
||||
await fs.expectFileToContain('dist/out.css', [
|
||||
//
|
||||
candidate`text-primary`,
|
||||
'color: red',
|
||||
])
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue