Skip to content

Commit

Permalink
Merge pull request #2 from natac13/chore/include-important
Browse files Browse the repository at this point in the history
chore: include important declaration in css global styles from WP
  • Loading branch information
natac13 authored Aug 7, 2023
2 parents 617b883 + 0717a2d commit ddf63fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ module.exports = {

The `globalStyles` option is required. It should be the contents of the WordPress global stylesheet.

## ⚠️ Warning

Any `!important` declarations in the WordPress global stylesheet will be preserved in the TailwindCSS base and components. Therefore, you should keep this in mind when writing your own TailwindCSS styles. And to check the TailwindCSS Intellisense to see when `!important` is being used.

## 🪪 License

MIT
Expand Down
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ module.exports = plugin.withOptions(
}

if (property.startsWith('--')) {
cssVariables[property] = value.replace(' !important', '')
// cssVariables[property] = value.replace(' !important', '')
cssVariables[property] = value
}
}
continue
Expand All @@ -102,7 +103,8 @@ module.exports = plugin.withOptions(
continue
}
const property = declaration.property
const value = declaration.value?.replace(' !important', '')
// const value = declaration.value?.replace(' !important', '')
const value = declaration.value

if (!property || !value) {
continue
Expand Down Expand Up @@ -135,7 +137,8 @@ module.exports = plugin.withOptions(
continue
}
const property = declaration.property
const value = declaration.value?.replace(' !important', '')
// const value = declaration.value?.replace(' !important', '')
const value = declaration.value

if (!property || !value) {
continue
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwindcss-wp-global-styles",
"version": "0.1.0",
"version": "0.1.1",
"description": "A TailwindCSS Plugin to take global styles from WordPress and convert them to TailwindCSS",
"main": "./index.js",
"types": "./index.d.ts",
Expand Down

0 comments on commit ddf63fc

Please sign in to comment.