Compiler specific settings¶
CoffeeScript¶
executable- Path to CoffeeScript compiler executable. Default:
"coffee". sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False.
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.CoffeeScript",
{
"executable": "/usr/bin/coffee",
"sourcemap_enabled": True,
},
),
)
Babel¶
executable- Path to Babel compiler executable. Default:
"babel". sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False. plugins- Babel plugins command line option. Default:
None(uses Babel’s default option). presets- Babel presets command line option. Default:
None(uses Babel’s default option).
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.Babel",
{
"executable": "/usr/bin/babel",
"sourcemap_enabled": True,
"plugins": "transform-react-jsx",
"presets": "es2015,react",
},
),
)
LiveScript¶
executable- Path to LiveScript compiler executable. Default:
"lsc". sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False.
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.LiveScript",
{
"executable": "/usr/bin/lsc",
"sourcemap_enabled": True,
},
),
)
Handlebars¶
executable- Path to Handlebars compiler executable. Default:
"handlebars". sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False. known_helpers- List of known helpers (
-kcompiler option). Default:None. namespace- Template namespace (
-ncompiler option). Default:None. simple- Output template function only (
-scompiler option). Default:False.
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.Handlebars",
{
"executable": "/usr/bin/handlebars",
"sourcemap_enabled": True,
"simple": True,
},
),
)
SASS / SCSS¶
Ruby-based (legacy) SASS compiler.
executable- Path to SASS compiler executable. Default: “sass”.
sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False. compass_enabled- Boolean. Whether to use compass or not. Compass must be installed in your system.
Run
sass --compassand if no error is shown it means that compass is installed. load_paths- List of additional directories to look imported files (
--load-pathcommand line option). Default:None. precision- How many digits of precision to use when outputting decimal numbers. Default:
None. Set this to 8 or more if you compile Bootstrap. output_style- Output style. Default:
None. Can be nested, compact, compressed, or expanded.
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.SCSS",
{
"executable": "/usr/bin/sass",
"sourcemap_enabled": True,
"compass_enabled": True,
"load_paths": ["/path"],
"precision": 8,
"output_style": "compressed",
},
),
)
Dart Sass¶
Dart Sass is the current implementation of SASS.
Note
Dart Sass compiler is not enabled by default. See the example below for how to enable it.
Options:
sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False. load_paths- List of additional paths to find imports. Default:
None. output_style- Output style. Default:
None. Can be “expanded” or “compressed”.
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.dart_sass.SCSS",
{
"sourcemap_enabled": True,
"load_paths": ["/path"],
},
),
(
"static_precompiler.compilers.dart_sass.SASS",
{
"sourcemap_enabled": True,
"load_paths": ["/path"],
"output_style": "compressed",
},
),
)
Libsass¶
Libsass is a C/C++ implementation of SASS.
django-static-precompiler uses libsass-python bindings for libsass
To use SASS / SCSS compiler based on libsass install django-static-precompiler with libsass flavor:
pip install django-static-precompiler[libsass]
Note
Libsass compiler is disabled by default. See how to enable it in the example below.
Options:
sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False. load_paths- List of additional paths to find imports. Default:
None. precision- How many digits of precision to use when outputting decimal numbers. Default:
None. Set this to 8 or more if you compile Bootstrap. output_style- Output style. Default:
None. Can be nested, compact, compressed, or expanded.
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.libsass.SCSS",
{
"sourcemap_enabled": True,
"load_paths": ["/path"],
"precision": 8,
},
),
(
"static_precompiler.compilers.libsass.SASS",
{
"sourcemap_enabled": True,
"load_paths": ["/path"],
"precision": 8,
"output_style": "compressed",
},
),
)
LESS¶
executable- Path to LESS compiler executable. Default:
"lessc". sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False. include_path- List of additional directories to look for imported files (
--include-pathcommand line option). Default:None. clean_css- Boolean. Set to
Trueto use the clean-css plugin to minify the output. DefaultFalse. global_vars- Dictionary of global variables (
--global-varcommand line option). Default:None.
Example:
STATIC_PRECOMPILER_COMPILERS = (
(
"static_precompiler.compilers.LESS",
{
"executable": "/usr/bin/lessc",
"sourcemap_enabled": True,
"global_vars": {"link-color": "red"},
},
),
)
Stylus¶
executable- Path to Stylus compiler executable. Default:
"stylus". sourcemap_enabled- Boolean. Set to
Trueto enable source maps. Default:False.
Example:
STATIC_PRECOMPILER_COMPILERS = (
("static_precompiler.compilers.Stylus", {"executable": "/usr/bin/stylus", "sourcemap_enabled": True}),
)