Skip to content

Commit ffae871

Browse files
committed
Revert "Allow plugins to register new config variables"
1 parent 5ea8bbe commit ffae871

File tree

4 files changed

+5
-63
lines changed

4 files changed

+5
-63
lines changed

__tests__/configFunction.test.js

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import _ from 'lodash'
21
import postcss from 'postcss'
3-
import config from '../defaultConfig.stub.js'
42
import plugin from '../src/lib/evaluateTailwindFunctions'
5-
import processPlugins from '../src/util/processPlugins'
63

7-
function run(input, opts = config) {
8-
return postcss([
9-
plugin(opts, processPlugins(_.get(opts, 'plugins', []), opts).configValues),
10-
]).process(input, {
11-
from: undefined,
12-
})
4+
function run(input, opts = {}) {
5+
return postcss([plugin(opts)]).process(input, { from: undefined })
136
}
147

158
test('it looks up values in the config using dot notation', () => {
@@ -87,48 +80,3 @@ test('quotes are preserved around default values', () => {
8780
expect(result.warnings().length).toBe(0)
8881
})
8982
})
90-
91-
test('plugins can register values that should be available to the config function', () => {
92-
const input = `
93-
.banana { color: config('banana.sandwich'); }
94-
`
95-
96-
const output = `
97-
.banana { color: blue; }
98-
`
99-
100-
return run(input, {
101-
plugins: [
102-
function({ addConfig }) {
103-
addConfig('banana', {
104-
sandwich: 'blue',
105-
})
106-
},
107-
],
108-
}).then(result => {
109-
expect(result.css).toMatchCss(output)
110-
expect(result.warnings().length).toBe(0)
111-
})
112-
})
113-
114-
test('plugin config values do not override first-class config values', () => {
115-
const input = `
116-
.banana { color: config('separator'); }
117-
`
118-
119-
const output = `
120-
.banana { color: _; }
121-
`
122-
123-
return run(input, {
124-
separator: '_',
125-
plugins: [
126-
function({ addConfig }) {
127-
addConfig('separator', '+')
128-
},
129-
],
130-
}).then(result => {
131-
expect(result.css).toMatchCss(output)
132-
expect(result.warnings().length).toBe(0)
133-
})
134-
})

src/lib/evaluateTailwindFunctions.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import _ from 'lodash'
22
import functions from 'postcss-functions'
33

4-
export default function(config, pluginConfigValues) {
4+
export default function(config) {
55
return functions({
66
functions: {
77
config: (path, defaultValue) => {
8-
const trimmedPath = _.trim(path, `'"`)
9-
return _.get(config, trimmedPath, _.get(pluginConfigValues, trimmedPath, defaultValue))
8+
return _.get(config, _.trim(path, `'"`), defaultValue)
109
},
1110
},
1211
})

src/processTailwindFeatures.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function(getConfig) {
1818

1919
return postcss([
2020
substituteTailwindAtRules(config, processedPlugins),
21-
evaluateTailwindFunctions(config, processedPlugins.configValues),
21+
evaluateTailwindFunctions(config),
2222
substituteVariantsAtRules(config, processedPlugins),
2323
substituteResponsiveAtRules(config),
2424
substituteScreenAtRules(config),

src/util/processPlugins.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export default function(plugins, config) {
1919
const pluginComponents = []
2020
const pluginUtilities = []
2121
const pluginVariantGenerators = {}
22-
const pluginConfigValues = {}
2322

2423
plugins.forEach(plugin => {
2524
plugin({
@@ -65,16 +64,12 @@ export default function(plugins, config) {
6564
addVariant: (name, generator) => {
6665
pluginVariantGenerators[name] = generateVariantFunction(generator)
6766
},
68-
addConfig: (namespace, value) => {
69-
pluginConfigValues[namespace] = value
70-
},
7167
})
7268
})
7369

7470
return {
7571
components: pluginComponents,
7672
utilities: pluginUtilities,
7773
variantGenerators: pluginVariantGenerators,
78-
configValues: pluginConfigValues,
7974
}
8075
}

0 commit comments

Comments
 (0)