Compiling SCSS Skin in Magento CE 1.9: Troubleshooting Common Issues
Magento’s default rwd skin provides a solid foundation for building custom themes, but developers often encounter issues during the SCSS compilation process. Let me guide you through resolving the common syntax error you’re facing.
Understanding the Error: Invalid CSS after “a:not(”
The error message points to line 541 in your scss/core/_common.scss file:
a:not(".button") {
//...your styles...
}
The issue lies with the notation inside the a:not() selector. Magento’s SCSS compiler expects a CSS class name without quotes, but it currently has the quotes around .button.
Resolving the Syntax Error
To fix this issue:
-
Open the
scss/core/_common.scssfile located in your theme directory. -
Modify line 541 to remove the surrounding quotes from the selector:
a:not(.button) {
//...your styles...
}
- Save the changes and re-compile your SCSS using the following command:
$ compass compile scss
After applying this change, the SCSS should compile successfully without throwing any syntax errors.
Best Practices for Theme Development
While editing core files is not ideal in a production environment due to potential upgrade conflicts, it’s acceptable during theme development. To maintain a clean and manageable codebase:
-
Use child themes: Create a child theme that inherits from the
rwdskin. This enables you to override styles without directly modifying the parent theme. -
Keep track of changes: Use version control systems like Git to monitor your modifications and easily revert if needed.
-
Test thoroughly: Ensure your theme works across different browsers, devices, and Magento versions before deployment.
Additional Resources
For a more detailed guide on Magento themes and SCSS compilation, I recommend checking out our comprehensive tutorial at Laravel Company: Mastering Magento Themes. It covers the entire process from start to finish with step-by-step instructions and best practices.
Conclusion
Resolving SCSS syntax errors in Magento themes often requires a keen eye for detail. In this case, removing unnecessary quotes from the selector fixed the issue and allowed successful compilation of your custom skin.
Remember to follow best practices like using child themes and version control to maintain a clean and reliable codebase throughout the development process.
Happy theming!