This library provides a simple Julian API to use the libsass library to compile scss and sass files to css.
using Sass
filename = joinpath(Sass.examplefolder, "test.sass")
Sass.compile_file(filename; precision = 1, source_comments = true)
To write the output to a file use the signature:
Sass.compile_file(filename, dest; kwargs...)
All libsass options can be passed as keyword arguments:
output_style
: output style for the generated css code. SeeSass.Style
for options. For exampleoutput_style = Sass.nested
source_comments
: a boolean to specify whether to insert inline source commentssource_map_file
: path to source map file, enables the source map generating used to create sourceMappingUrlomit_source_map_url
: disable sourceMappingUrl in css outputsource_map_embed
: embed sourceMappingUrl as data urisource_map_contents
: embed include contents in mapssource_map_file_urls
: create file urls for sourcessource_map_root
: pass-through as sourceRoot propertyis_indented_syntax_src
: treat source_string as sass (as opposed to scss)include_path
(AbstractString
orAbstractArray{<:AbstractString}
)plugin_path
(AbstractString
orAbstractArray{<:AbstractString}
)indent
: string to be used for indentationlinefeed
: string to be used to for line feedsinput_path
: the input path is used for source map generating. It can be used to define something with string compilation or to overload the input file path. It is set tostdin
for data contexts and to the input file on file contexts.output_path
: the output path is used for source map generating. LibSass will not write to this file, it is just used to create information in source-maps etc.precision
: precision for outputting fractional numbers
For more advanced use, the main functions of the libsass API are ported and can be used directly for a finer control. This is more complicated and should be unnecessary in most cases.
using Sass
filename = joinpath(Sass.examplefolder, "test.sass")
context = sass_make_file_context(filename)
options = sass_file_context_get_options(context)
sass_option_set_precision(options, 1)
sass_option_set_source_comments(options, true)
sass_file_context_set_options(context, options)
compiler = sass_make_file_compiler(context)
sass_compiler_parse(compiler)
sass_compiler_execute(compiler)
output = sass_context_get_output_string(context)
# Retrieve errors during compilation
error_status = sass_context_get_error_status(context)
json_error = sass_context_get_error_json(context)
# Release memory dedicated to the C compiler
sass_delete_compiler(compiler)