Skip to main content

Using libsass, compile all .scss files found in the paths defined in settings.STATICFILES_FINDERS.

Project description

PyPI PyPI - Python Version PyPI - Django Version PyPI - Wheel PyPI - Downloads

django-sass-compiler

Simplify the use of Sass in Django

Using libsass, compile all .scss files found in the paths defined in settings.STATICFILES_FINDERS


Quickstart

1.- It's available on PyPI, so you can install it using pip

pip install django-sass-compiler

2.- Add django_sass_compiler to your INSTALLED_APPS

INSTALLED_APPS = [
    ...,
    'django_sass_compiler',
]

3.- Run sass-compiler

python manage.py sass-compiler

or combine with runserver command, useful with --watch argument.

python manage.py runserver & python manage.py sass-compiler --watch

Arguments:

All arguments are optional and combinable

  • -s, --style

    Coding style of the compiled result. choose one of: 'nested', 'expanded' (default), 'compact', 'compressed'

  • -p, --precision

    Sets the number of digits of precision. 8 by default.

  • -nb, --no-build

    Don't create build folder.

    app/
      |- static/
         |- app/
            |- scss/
               |- style.scss
            |- css/
               |- style.css
    

    instead

    app/
      |- static/
         |- app/
            |- scss/
               |- style.scss
            |- build/
               |- css/
                  |- style.css
    
  • -m, --map

    Build a source map.

  • -c, --clean

    Remove old files before new compilation.

    NOTE: This action will only take effect on current destination folder (--no-build).

  • -w, --watch

    Watch and compile files when .scss files are changed.

  • -i, --ignore

    Ignore files or directories matching this glob-style pattern. Use multiple times to ignore more.

    You can also define list paths to ignore in settings.SASS_COMPILER_IGNORE_PATTERNS environment variable.

    SASS_COMPILER_IGNORE_PATTERNS = [
       'app/scss/style.scss',
       'app/scss/test/*'
    ]
    

    NOTE: All patterns will applied in the path since the static folder to the file name.

    Example:

    To ignore apps/app/static/app/scss/style.scss the longest path would be:

    python manage.py sass-compiler --ignore=app/scss/style.scss or

    python manage.py sass-compiler -i=**/**/style.scss

    or some other glob-style pattern.

@import

To @import .scss files you must use absolute paths unless the files are at the same or less level, in that case you can use relative paths

some-app/
  |- static/
     |- some-app/
        |- scss/
            |- pages
                |- _timeline.scss
            |- _colors.scss
            |- style.scss
other-app/
  |- static/
     |- other-app/
        |- scss/
            |- _variables.scss

some-app/style.scss

@import 'other-app/scss/variables';
@import 'pages/timeline';
@import 'colors'
### WRONG ###
@import '../../variables'; 

Outputs

Standard output:
$ python manage.py sass-compiler 
app/
  |- static/
     |- app/
        |- scss/
           |- _colors.scss
           |- style.scss
        |- build/
           |- css/
              |- style.css
With some argument output:
python manage.py sass-compiler --style=compressed --no-build --map
app/
  |- static/
     |- app/
        |- scss/
           |- _colors.scss
           |- style.scss
        |- css/
           |- style.min.css
           |- style.css.map

Licensing

The project is licensed under the BSD License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

django_sass_compiler-1.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file django_sass_compiler-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_sass_compiler-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.1

File hashes

Hashes for django_sass_compiler-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8517338eb788792d3340c1ce8e0a906b06da191d819672ce4acbaba29564fd42
MD5 1719f2b62ddacff40056dd2a4d01c9c0
BLAKE2b-256 283213fa1cb8ecf7cb9a9e7ac39e6fd6b5a1dc7ac53714bffc79c04740cd594d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page