mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Move some config error checking out of resolveConfig (#8362)
This commit is contained in:
parent
638c8f43ea
commit
0313f02e2c
@ -17,6 +17,7 @@ import getModuleDependencies from './lib/getModuleDependencies'
|
||||
import log from './util/log'
|
||||
import packageJson from '../package.json'
|
||||
import normalizePath from 'normalize-path'
|
||||
import { validateConfig } from './util/validateConfig.js'
|
||||
|
||||
let env = {
|
||||
DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
|
||||
@ -490,10 +491,13 @@ async function build() {
|
||||
let files = args['--content'].split(/(?<!{[^}]+),/)
|
||||
let resolvedConfig = resolveConfigInternal(config, { content: { files } })
|
||||
resolvedConfig.content.files = files
|
||||
resolvedConfig = validateConfig(resolvedConfig)
|
||||
return resolvedConfig
|
||||
}
|
||||
|
||||
return resolveConfigInternal(config)
|
||||
let resolvedConfig = resolveConfigInternal(config)
|
||||
resolvedConfig = validateConfig(resolvedConfig)
|
||||
return resolvedConfig
|
||||
}
|
||||
|
||||
function extractFileGlobs(config) {
|
||||
|
||||
@ -16,6 +16,7 @@ import { env } from './sharedState'
|
||||
|
||||
import { getContext, getFileModifiedMap } from './setupContextUtils'
|
||||
import parseDependency from '../util/parseDependency'
|
||||
import { validateConfig } from '../util/validateConfig.js'
|
||||
|
||||
let configPathCache = new LRU({ maxSize: 100 })
|
||||
|
||||
@ -63,6 +64,7 @@ function getTailwindConfig(configOrPath) {
|
||||
delete require.cache[file]
|
||||
}
|
||||
let newConfig = resolveConfig(require(userConfigPath))
|
||||
newConfig = validateConfig(newConfig)
|
||||
let newHash = hash(newConfig)
|
||||
configPathCache.set(userConfigPath, [newConfig, newHash, newDeps, newModified])
|
||||
return [newConfig, userConfigPath, newHash, newDeps]
|
||||
@ -73,6 +75,8 @@ function getTailwindConfig(configOrPath) {
|
||||
configOrPath.config === undefined ? configOrPath : configOrPath.config
|
||||
)
|
||||
|
||||
newConfig = validateConfig(newConfig)
|
||||
|
||||
return [newConfig, null, hash(newConfig), []]
|
||||
}
|
||||
|
||||
|
||||
@ -258,13 +258,5 @@ export function normalizeConfig(config) {
|
||||
}
|
||||
}
|
||||
|
||||
if (config.content.files.length === 0) {
|
||||
log.warn('content-problems', [
|
||||
'The `content` option in your Tailwind CSS configuration is missing or empty.',
|
||||
'Configure your content sources or your generated CSS will be missing styles.',
|
||||
'https://tailwindcss.com/docs/content-configuration',
|
||||
])
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
13
src/util/validateConfig.js
Normal file
13
src/util/validateConfig.js
Normal file
@ -0,0 +1,13 @@
|
||||
import log from './log'
|
||||
|
||||
export function validateConfig(config) {
|
||||
if (config.content.files.length === 0) {
|
||||
log.warn('content-problems', [
|
||||
'The `content` option in your Tailwind CSS configuration is missing or empty.',
|
||||
'Configure your content sources or your generated CSS will be missing styles.',
|
||||
'https://tailwindcss.com/docs/content-configuration',
|
||||
])
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user