mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Revert "Allow plugins to register new config variables"
This commit is contained in:
parent
5ea8bbe798
commit
ffae87148d
@ -1,15 +1,8 @@
|
||||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import config from '../defaultConfig.stub.js'
|
||||
import plugin from '../src/lib/evaluateTailwindFunctions'
|
||||
import processPlugins from '../src/util/processPlugins'
|
||||
|
||||
function run(input, opts = config) {
|
||||
return postcss([
|
||||
plugin(opts, processPlugins(_.get(opts, 'plugins', []), opts).configValues),
|
||||
]).process(input, {
|
||||
from: undefined,
|
||||
})
|
||||
function run(input, opts = {}) {
|
||||
return postcss([plugin(opts)]).process(input, { from: undefined })
|
||||
}
|
||||
|
||||
test('it looks up values in the config using dot notation', () => {
|
||||
@ -87,48 +80,3 @@ test('quotes are preserved around default values', () => {
|
||||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
test('plugins can register values that should be available to the config function', () => {
|
||||
const input = `
|
||||
.banana { color: config('banana.sandwich'); }
|
||||
`
|
||||
|
||||
const output = `
|
||||
.banana { color: blue; }
|
||||
`
|
||||
|
||||
return run(input, {
|
||||
plugins: [
|
||||
function({ addConfig }) {
|
||||
addConfig('banana', {
|
||||
sandwich: 'blue',
|
||||
})
|
||||
},
|
||||
],
|
||||
}).then(result => {
|
||||
expect(result.css).toMatchCss(output)
|
||||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
test('plugin config values do not override first-class config values', () => {
|
||||
const input = `
|
||||
.banana { color: config('separator'); }
|
||||
`
|
||||
|
||||
const output = `
|
||||
.banana { color: _; }
|
||||
`
|
||||
|
||||
return run(input, {
|
||||
separator: '_',
|
||||
plugins: [
|
||||
function({ addConfig }) {
|
||||
addConfig('separator', '+')
|
||||
},
|
||||
],
|
||||
}).then(result => {
|
||||
expect(result.css).toMatchCss(output)
|
||||
expect(result.warnings().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
import _ from 'lodash'
|
||||
import functions from 'postcss-functions'
|
||||
|
||||
export default function(config, pluginConfigValues) {
|
||||
export default function(config) {
|
||||
return functions({
|
||||
functions: {
|
||||
config: (path, defaultValue) => {
|
||||
const trimmedPath = _.trim(path, `'"`)
|
||||
return _.get(config, trimmedPath, _.get(pluginConfigValues, trimmedPath, defaultValue))
|
||||
return _.get(config, _.trim(path, `'"`), defaultValue)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -18,7 +18,7 @@ export default function(getConfig) {
|
||||
|
||||
return postcss([
|
||||
substituteTailwindAtRules(config, processedPlugins),
|
||||
evaluateTailwindFunctions(config, processedPlugins.configValues),
|
||||
evaluateTailwindFunctions(config),
|
||||
substituteVariantsAtRules(config, processedPlugins),
|
||||
substituteResponsiveAtRules(config),
|
||||
substituteScreenAtRules(config),
|
||||
|
||||
@ -19,7 +19,6 @@ export default function(plugins, config) {
|
||||
const pluginComponents = []
|
||||
const pluginUtilities = []
|
||||
const pluginVariantGenerators = {}
|
||||
const pluginConfigValues = {}
|
||||
|
||||
plugins.forEach(plugin => {
|
||||
plugin({
|
||||
@ -65,9 +64,6 @@ export default function(plugins, config) {
|
||||
addVariant: (name, generator) => {
|
||||
pluginVariantGenerators[name] = generateVariantFunction(generator)
|
||||
},
|
||||
addConfig: (namespace, value) => {
|
||||
pluginConfigValues[namespace] = value
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@ -75,6 +71,5 @@ export default function(plugins, config) {
|
||||
components: pluginComponents,
|
||||
utilities: pluginUtilities,
|
||||
variantGenerators: pluginVariantGenerators,
|
||||
configValues: pluginConfigValues,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user