Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f5c0e30

Browse files
committedMay 1, 2020
Fix bug where browserslist target didn't work outside of tuple syntax
1 parent 6aef917 commit f5c0e30

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed
 

‎__tests__/targetMode.test.js

+37
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,43 @@ test('plugins can request the target for a specific plugin key', () => {
8383
})
8484

8585
test('browserslist target is translated to a target preset', () => {
86+
return runInTempDirectory(() => {
87+
fs.writeFileSync(
88+
path.resolve('./.browserslistrc'),
89+
`
90+
last 2 versions
91+
IE 11
92+
`
93+
)
94+
const { utilities } = processPlugins(
95+
[
96+
function({ addUtilities, target }) {
97+
addUtilities({
98+
'.test': {
99+
target: target('testPlugin'),
100+
},
101+
})
102+
},
103+
],
104+
{
105+
...config,
106+
target: 'browserslist',
107+
}
108+
)
109+
110+
expect(css(utilities)).toMatchCss(`
111+
@variants {
112+
.test {
113+
target: ie11
114+
}
115+
}
116+
`)
117+
118+
return Promise.resolve()
119+
})
120+
})
121+
122+
test('browserslist target is translated to a target preset with overrides', () => {
86123
return runInTempDirectory(() => {
87124
fs.writeFileSync(
88125
path.resolve('./.browserslistrc'),

‎src/util/processPlugins.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function(plugins, config) {
5757
},
5858
target: path => {
5959
if (_.isString(config.target)) {
60-
return config.target
60+
return config.target === 'browserslist' ? browserslistTarget : config.target
6161
}
6262

6363
const [defaultTarget, targetOverrides] = getConfigValue('target')

0 commit comments

Comments
 (0)
Please sign in to comment.