Tsubasa ,

關於部落格
  自由之翼,
  • 5309

    累積人氣

  • 0

    今日人氣

    0

    訂閱人氣

資料/Django and SCSS.


--


 

  另一個選擇:https://github.com/jrief/django-sass-processor

  可能是中文教學:http://www.oxxostudio.tw/articles/201503/gulp-4-scss-sass.html

  SCSS 教學/官方 Guide:Link (全英文注意)

--

Integration with Django

SASS can be easily included into your Django project by using Django Compressor. Firstly, you must install SASS, which requires Ruby, by using the command:

gem install SASS

Next, you must follow the steps to get Django Compressor up and running. Finally, you must add the following pre-compiler to your projects settings file:

COMPRESS_PRECOMPILERS = (
    ('text/scss', 'sass --scss {infile} {outfile}'),
)

Now you are ready to use SASS in your project! just include the compress template tag around your stylesheet links:

{% load compress %}
{% load staticfiles %}

{% compress css %}
    <link rel="stylesheet" type="text/scss" href="{% static 'styles.scss' %}" />
{% endcompress %}

And your SASS will be compiled into CSS on the fly!

Using Compass

Compass is a SASS library that includes blueprints and mixins that make writing stylesheets with SASS even easier. The Compass docs explain all of the mixins that are included and some examples of how you can use them. Integrating Compass with your SASS requires a little bit of extra work when using Django Compressor. Firstly, make sure you install compass with the following command:

gem install compass

Next, you will need to make sure that if you have previously installed SASS, you delete it and use the version that comes with Compass. Compass doesn't always play nicely with the newest version of SASS, so it is important that you take this step. All you have to do from here is modify your COMPRESS_PRECOMPILERS in your project settings. Replace the previous pre-compiler with the following:

('text/scss', 'sass --scss --compass {infile} {outfile}')

That's it, you are now ready to use SASS with the added power of Compass in your Django project!

相簿設定
標籤設定
相簿狀態