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, --styleCoding style of the compiled result. choose one of:
'nested','expanded'(default),'compact','compressed'You can also define this argument in
settings.SASS_COMPILER_STYLEenvironment variable.SASS_COMPILER_STYLE = 'compressed' -
-p, --precisionSets the number of digits of precision. 8 by default.
You can also define this argument in
settings.SASS_COMPILER_PRECISIONenvironment variable.SASS_COMPILER_PRECISION = 5 -
-nb, --no-buildDon't create
buildfolder.app/ |- static/ |- app/ |- scss/ |- style.scss |- css/ |- style.cssinstead
app/ |- static/ |- app/ |- scss/ |- style.scss |- build/ |- css/ |- style.cssYou can also define this argument in
settings.SASS_COMPILER_NO_BUILDenvironment variable.SASS_COMPILER_NO_BUILD = True -
-m, --mapBuild a source map.
You can also define this argument in
settings.SASS_COMPILER_MAPenvironment variable.SASS_COMPILER_MAP = True -
-c, --cleanRemove old files before new compilation.
NOTE: This action will only take effect on current destination folder (
--no-build).You can also define this argument in
settings.SASS_COMPILER_CLEANenvironment variable.SASS_COMPILER_CLEAN = True -
-w, --watchWatch and compile files when
.scssfiles are changed.You can also define this argument in
settings.SASS_COMPILER_WATCHenvironment variable.SASS_COMPILER_WATCH = True -
-i, --ignoreIgnore files or directories matching this glob-style pattern. Use multiple times to ignore more.
NOTE: All patterns will applied in the path since the
staticfolder to the file name.Example:
To ignore
apps/app/static/app/scss/style.scssthe longest path would be:python manage.py sass-compiler --ignore=app/scss/style.scssorpython manage.py sass-compiler -i=**/**/style.scssor some other glob-style pattern.
You can also define list paths to ignore in
settings.SASS_COMPILER_IGNOREenvironment variable.SASS_COMPILER_IGNORE = [ 'app/scss/style.scss', 'app/scss/test/*' ]
@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.
Metadata
Release files for django-sass-compiler 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_sass_compiler-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / django_sass_compiler-1.1.0-py3-none-any.whl
| Download URL | django_sass_compiler-1.1.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4f0eae81318b32c935cdbb549d6e33b44524e8f5a2cd151713226d7a3f28cb1
|
|
BLAKE2b-256 checksum How to use checksums |
ea13856733ace09003722a480893ffcac7e2891bc91cbba3dbb7d2dabb971647
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|