mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Add mode option to use JIT code path
This commit is contained in:
parent
66765c18e5
commit
db2c661048
20
src/index.js
20
src/index.js
@ -11,6 +11,7 @@ import resolveConfig from './util/resolveConfig'
|
||||
import getAllConfigs from './util/getAllConfigs'
|
||||
import { supportedConfigFiles } from './constants'
|
||||
import defaultConfig from '../stubs/defaultConfig.stub.js'
|
||||
import log from './util/log'
|
||||
|
||||
function resolveConfigPath(filePath) {
|
||||
// require('tailwindcss')({ theme: ..., variants: ... })
|
||||
@ -65,8 +66,19 @@ const getConfigFunction = (config) => () => {
|
||||
}
|
||||
|
||||
module.exports = function (config) {
|
||||
const plugins = []
|
||||
const resolvedConfigPath = resolveConfigPath(config)
|
||||
const getConfig = getConfigFunction(resolvedConfigPath || config)
|
||||
const mode = _.get(getConfig(), 'mode', 'aot')
|
||||
|
||||
if (mode === 'jit') {
|
||||
log.warn([
|
||||
`You have enabled the JIT engine which is currently in preview.`,
|
||||
'Preview features are not covered by semver, may introduce breaking changes, and can change at any time.',
|
||||
])
|
||||
return require('../jit/index.js')(config)
|
||||
}
|
||||
|
||||
const plugins = []
|
||||
|
||||
if (!_.isUndefined(resolvedConfigPath)) {
|
||||
plugins.push(registerConfigAsDependency(resolvedConfigPath))
|
||||
@ -74,11 +86,7 @@ module.exports = function (config) {
|
||||
|
||||
return {
|
||||
postcssPlugin: 'tailwindcss',
|
||||
plugins: [
|
||||
...plugins,
|
||||
processTailwindFeatures(getConfigFunction(resolvedConfigPath || config)),
|
||||
formatCSS,
|
||||
],
|
||||
plugins: [...plugins, processTailwindFeatures(getConfig), formatCSS],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user