Django-Bower + Foundation 5 + SASS, How to configure?

前端 未结 2 410
暗喜
暗喜 2020-12-24 14:12

I\'m in the process of testing out a SASS implementation of Foundation 5 using Django-Bower. I\'m new to the idea of Bower and am having a bit of confusion as to how to get

2条回答
  •  梦毁少年i
    2020-12-24 14:31

    packages:

    1. django-pipeline
    2. django-bower

    How to compile with django-pipeline:

    application.scss:

    @import "../../../components/bower_components/foundation/scss/foundation";
    

    settings.py:

    INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
    
        'pipeline',
        'djangobower',
    )
    
    BOWER_COMPONENTS_ROOT = os.path.join(BASE_DIR, 'components')
    
    STATICFILES_FINDERS = (
        .....
        'djangobower.finders.BowerFinder',  # just for bower components
    
    )
    
    PIPELINE_CSS = {
        'application': {
            'source_filenames': (
                'css/application.scss',
            ),
            'output_filename': 'css/application.css',
            'extra_context': {
                'media': 'screen,projection',
            },
        },
    }
    
    PIPELINE_COMPILERS = (
        'pipeline.compilers.sass.SASSCompiler',
    )
    

    Then in template:

    {% load compressed %}
    {% compressed_css 'application' %}
    

    This will compile on developemnt and on collectstatic will compile and compress

提交回复
热议问题