Automattic / _s

Hi. I'm a starter theme called _s, or underscores, if you like. I'm a theme meant for hacking so don't use me as a Parent Theme. Instead try turning me into the next, most awesome, WordPress theme out there. That's what I'm here for.
http://underscores.me/
GNU General Public License v2.0
10.94k stars 3.12k forks source link

Add SASS compilation and sync the CSS files #1391

Closed Ismail-elkorchi closed 4 years ago

Ismail-elkorchi commented 4 years ago

Changes proposed in this Pull Request:

In this PR I added the command compile:css to package.json to compile SASS files using node-sass. The problem is that node-sass has some weird behavior when it comes to comments and nesting. This is something that is known since the early attempts to automate the compilation of CSS https://github.com/Automattic/_s/pull/1168#issuecomment-314131813.

To address this issue, I chained stylelint --fix script to node-sass in compile:css command, but that was not enough, because stylelint didn't fix all the issue in the first pass. So I made the compile:css command run the stylelint --fix twice :

"compile:css": "node-sass sass/style.scss style.css && node-sass sass/woocommerce.scss woocommerce.css && stylelint '*.css' --fix || true && stylelint '*.css' --fix"

For the CSS inline comment problem, I borrowed the solution suggested by @m-e-h in the comment mentioned above. And by the way I removed some redundant comments.

The changes made to style.css and woocommerce.css were generated using the compile:css command.

Related issue(s):

https://github.com/Automattic/_s/issues/1149, https://github.com/Automattic/_s/pull/1159, https://github.com/Automattic/_s/pull/1168, https://github.com/Automattic/_s/pull/1237, https://github.com/Automattic/_s/pull/1221, https://github.com/Automattic/_s/pull/932