mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Allowed the 'build' cli command to fallback to some defaults if no input file is specified.
This commit is contained in:
parent
50ce88ab37
commit
d833174b4e
@ -43,12 +43,20 @@ describe('cli', () => {
|
||||
})
|
||||
|
||||
describe('build', () => {
|
||||
it('compiles CSS file', () => {
|
||||
it('compiles CSS file using an input css file', () => {
|
||||
return cli(['build', inputCssPath]).then(() => {
|
||||
expect(process.stdout.write.mock.calls[0][0]).toContain('.example')
|
||||
})
|
||||
})
|
||||
|
||||
it('compiles CSS file without an input css file', () => {
|
||||
return cli(['build']).then(() => {
|
||||
expect(process.stdout.write.mock.calls[0][0]).toContain('normalize.css') // base
|
||||
expect(process.stdout.write.mock.calls[0][0]).toContain('.container') // components
|
||||
expect(process.stdout.write.mock.calls[0][0]).toContain('.mx-auto') // utilities
|
||||
})
|
||||
})
|
||||
|
||||
it('compiles CSS file using custom configuration', () => {
|
||||
return cli(['build', inputCssPath, '--config', customConfigPath]).then(() => {
|
||||
expect(process.stdout.write.mock.calls[0][0]).toContain('400px')
|
||||
|
||||
@ -80,7 +80,7 @@ function buildToFile(compileOptions, startTime) {
|
||||
|
||||
utils.header()
|
||||
utils.log()
|
||||
utils.log(emoji.go, 'Building...', colors.file(inputFileSimplePath))
|
||||
utils.log(emoji.go, 'Building...', colors.file(inputFileSimplePath || 'defaults: @base, @components and @utilities.'))
|
||||
|
||||
return compile(compileOptions).then(result => {
|
||||
utils.writeFile(compileOptions.outputFile, result.css)
|
||||
@ -112,8 +112,9 @@ export function run(cliParams, cliOptions) {
|
||||
const inputFileSimplePath = utils.getSimplePath(inputFile)
|
||||
const configFileSimplePath = utils.getSimplePath(configFile)
|
||||
|
||||
!inputFile && stopWithHelp('CSS file is required.')
|
||||
!utils.exists(inputFile) && stop(colors.file(inputFileSimplePath), 'does not exist.')
|
||||
if (inputFile) {
|
||||
!utils.exists(inputFile) && stop(colors.file(inputFileSimplePath), 'does not exist.')
|
||||
}
|
||||
|
||||
configFile &&
|
||||
!utils.exists(configFile) &&
|
||||
|
||||
@ -25,7 +25,12 @@ const defaultOptions = {
|
||||
*/
|
||||
export default function compile(options = {}) {
|
||||
const config = { ...defaultOptions, ...options }
|
||||
const css = utils.readFile(config.inputFile)
|
||||
|
||||
const css = config.inputFile ? utils.readFile(config.inputFile) : `
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
`;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
postcss(config.plugins)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user