Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
143 views
in Technique[技术] by (71.8m points)

php - Sass with wordpress

Does anyone know the best method for including sass into wordpress. I am trying to practice without a starter theme, but every online tutorial even in the last year, seem to be outdated and doesnt work. How do you include sass into your wordpress theme?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I use Gulp and the gulp-sass package inside a custom theme, but you can also include it in a plugin if you don't want to work inside a theme. Gulp is easy to set up if you have some experience installing npm packages:

https://www.npmjs.com/package/gulp-sass

I have a folder specifically for gulp with the sass files and folders in there. You can pipe the compiled css files anywhere in your plugin/theme. Wherever you need them to work. Then register the compiled files with wordpress hook:

https://developer.wordpress.org/reference/functions/wp_enqueue_style/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...