mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Support passing config path via object
This commit is contained in:
parent
7877ffab8a
commit
649fb8f21e
@ -68,6 +68,33 @@ test('custom config can be passed as an object', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('custom config path can be passed using `config` property in an object', () => {
|
||||
return postcss([tailwind({ config: path.resolve(`${__dirname}/fixtures/custom-config.js`) })])
|
||||
.process(
|
||||
`
|
||||
@responsive {
|
||||
.foo {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
`,
|
||||
{ from: undefined }
|
||||
)
|
||||
.then(result => {
|
||||
const expected = `
|
||||
.foo {
|
||||
color: blue;
|
||||
}
|
||||
@media (min-width: 400px) {
|
||||
.mobile\\:foo {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
`
|
||||
expect(result.css).toMatchCss(expected)
|
||||
})
|
||||
})
|
||||
|
||||
test('tailwind.config.js is picked up by default', () => {
|
||||
return inTempDirectory(() => {
|
||||
fs.writeFileSync(
|
||||
|
||||
@ -13,10 +13,14 @@ import { defaultConfigFile } from './constants'
|
||||
import defaultConfig from '../stubs/defaultConfig.stub.js'
|
||||
|
||||
function resolveConfigPath(filePath) {
|
||||
if (_.isObject(filePath)) {
|
||||
if (_.isObject(filePath) && !_.has(filePath, 'config')) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
if (_.isObject(filePath) && _.has(filePath, 'config')) {
|
||||
return path.resolve(filePath.config)
|
||||
}
|
||||
|
||||
if (!_.isUndefined(filePath)) {
|
||||
return path.resolve(filePath)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user