Skip to content

Commit

Permalink
Ignore !important when sorting @apply classes (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradlc authored Jan 24, 2022
1 parent fbb565a commit b75ddb2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ function transformJavaScript(ast, { env }) {
function transformCss(ast, { env }) {
ast.walk((node) => {
if (node.type === 'css-atrule' && node.name === 'apply') {
node.params = sortClasses(node.params, { env })
node.params = sortClasses(node.params, {
env,
ignoreLast: /\s+(?:!important|#{!important})\s*$/.test(node.params),
})
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ let tests = {
...vue.map((test) => test.map((t) => t.replace(/:class=/g, '[ngClass]='))),
t`<div [ngClass]='\`${yes} \${someVar} ${yes} \${"${yes}"}\`'></div>`,
],
css,
scss: css,
less: css,
css: [...css, t`@apply ${yes} !important;`],
scss: [...css, t`@apply ${yes} #{!important};`],
less: [...css, t`@apply ${yes} !important;`],
babel: javascript,
typescript: javascript,
'babel-ts': javascript,
Expand Down

0 comments on commit b75ddb2

Please sign in to comment.