Skip to content

Commit b75ddb2

Browse files
authored
Ignore !important when sorting @apply classes (#4)
1 parent fbb565a commit b75ddb2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ function transformJavaScript(ast, { env }) {
288288
function transformCss(ast, { env }) {
289289
ast.walk((node) => {
290290
if (node.type === 'css-atrule' && node.name === 'apply') {
291-
node.params = sortClasses(node.params, { env })
291+
node.params = sortClasses(node.params, {
292+
env,
293+
ignoreLast: /\s+(?:!important|#{!important})\s*$/.test(node.params),
294+
})
292295
}
293296
})
294297
}

tests/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ let tests = {
126126
...vue.map((test) => test.map((t) => t.replace(/:class=/g, '[ngClass]='))),
127127
t`<div [ngClass]='\`${yes} \${someVar} ${yes} \${"${yes}"}\`'></div>`,
128128
],
129-
css,
130-
scss: css,
131-
less: css,
129+
css: [...css, t`@apply ${yes} !important;`],
130+
scss: [...css, t`@apply ${yes} #{!important};`],
131+
less: [...css, t`@apply ${yes} !important;`],
132132
babel: javascript,
133133
typescript: javascript,
134134
'babel-ts': javascript,

0 commit comments

Comments
 (0)