Module: Sass

Defined in:
lib/sass/embedded.rb,
lib/sass/elf.rb,
lib/sass/value.rb,
lib/sass/compiler.rb,
lib/sass/exception.rb,
lib/sass/value/map.rb,
lib/sass/serializer.rb,
lib/sass/value/list.rb,
lib/sass/value/null.rb,
lib/sass/value/color.rb,
lib/sass/value/mixin.rb,
lib/sass/fork_tracker.rb,
lib/sass/value/number.rb,
lib/sass/value/string.rb,
lib/sass/compiler/host.rb,
lib/sass/logger/silent.rb,
lib/sass/value/boolean.rb,
lib/sass/compile_result.rb,
lib/sass/value/function.rb,
lib/sass/compiler/varint.rb,
lib/sass/compiler/channel.rb,
lib/sass/embedded/version.rb,
lib/sass/value/fuzzy_math.rb,
lib/sass/calculation_value.rb,
lib/sass/embedded_protocol.rb,
lib/sass/value/calculation.rb,
lib/sass/value/number/unit.rb,
lib/sass/logger/source_span.rb,
lib/sass/compiler/connection.rb,
lib/sass/compiler/dispatcher.rb,
lib/sass/value/argument_list.rb,
lib/sass/canonicalize_context.rb,
lib/sass/node_package_importer.rb,
lib/sass/logger/source_location.rb,
lib/sass/compiler/host/protofier.rb,
lib/sass/compiler/host/structifier.rb,
lib/sass/compiler/host/logger_registry.rb,
lib/sass/compiler/host/function_registry.rb,
lib/sass/compiler/host/importer_registry.rb,
lib/sass/calculation_value/calculation_operation.rb,
ext/sass/embedded_sass_pb.rb

Overview

The Sass module.

This communicates with Embedded Dart Sass using the Embedded Sass protocol.

Examples:

Sass.compile('style.scss')
Sass.compile_string('h1 { font-size: 40px; }')

Defined Under Namespace

Modules: CalculationValue, Embedded, Logger, Value Classes: CanonicalizeContext, CompileError, CompileResult, Compiler, NodePackageImporter, ScriptError

Class Method Summary collapse

Class Method Details

.compile(path, load_paths: [], charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, fatal_deprecations: [], future_deprecations: [], logger: nil, quiet_deps: false, silence_deprecations: [], verbose: false) ⇒ CompileResult

Compiles the Sass file at path to CSS.

Parameters:

  • path (String)
  • load_paths (Array<String>)

    Paths in which to look for stylesheets loaded by rules like @use and @import.

  • charset (Boolean)

    By default, if the CSS document contains non-ASCII characters, Sass adds a @charset declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to browsers or other consumers. If charset is false, these annotations are omitted.

  • source_map (Boolean)

    Whether or not Sass should generate a source map.

  • source_map_include_sources (Boolean)

    Whether Sass should include the sources in the generated source map.

  • style (Symbol)

    The OutputStyle of the compiled CSS.

  • functions (Hash<String, Proc>)

    Additional built-in Sass functions that are available in all stylesheets.

  • importers (Array<Object>)

    Custom importers that control how Sass resolves loads from rules like @use and @import.

  • alert_ascii (Boolean)

    If this is true, the compiler will exclusively use ASCII characters in its error and warning messages. Otherwise, it may use non-ASCII Unicode characters as well.

  • alert_color (Boolean)

    If this is true, the compiler will use ANSI color escape codes in its error and warning messages. If it’s false, it won’t use these. If it’s nil, the compiler will determine whether or not to use colors depending on whether the user is using an interactive terminal.

  • fatal_deprecations (Array<String>)

    A set of deprecations to treat as fatal.

  • future_deprecations (Array<String>)

    A set of future deprecations to opt into early.

  • logger (Object)

    An object to use to handle warnings and/or debug messages from Sass.

  • quiet_deps (Boolean)

    If this option is set to true, Sass won’t print warnings that are caused by dependencies. A “dependency” is defined as any file that’s loaded through load_paths or importer. Stylesheets that are imported relative to the entrypoint are not considered dependencies.

  • silence_deprecations (Array<String>)

    A set of active deprecations to ignore.

  • verbose (Boolean)

    By default, Dart Sass will print only five instances of the same deprecation warning per compilation to avoid deluging users in console noise. If you set verbose to true, it will instead print every deprecation warning it encounters.

Returns:

Raises:

See Also:



26
27
28
# File 'lib/sass/embedded.rb', line 26

def compile(...)
  compiler.compile(...)
end

.compile_string(source, importer: nil, load_paths: [], syntax: :scss, url: nil, charset: true, source_map: false, source_map_include_sources: false, style: :expanded, functions: {}, importers: [], alert_ascii: false, alert_color: nil, fatal_deprecations: [], future_deprecations: [], logger: nil, quiet_deps: false, silence_deprecations: [], verbose: false) ⇒ CompileResult

Compiles a stylesheet whose contents is source to CSS.

Parameters:

  • source (String)
  • importer (Object)

    The importer to use to handle loads that are relative to the entrypoint stylesheet.

  • load_paths (Array<String>)

    Paths in which to look for stylesheets loaded by rules like @use and @import.

  • syntax (Symbol)

    The Syntax to use to parse the entrypoint stylesheet.

  • url (String)

    The canonical URL of the entrypoint stylesheet. If this is passed along with importer, it’s used to resolve relative loads in the entrypoint stylesheet.

  • charset (Boolean)

    By default, if the CSS document contains non-ASCII characters, Sass adds a @charset declaration (in expanded output mode) or a byte-order mark (in compressed mode) to indicate its encoding to browsers or other consumers. If charset is false, these annotations are omitted.

  • source_map (Boolean)

    Whether or not Sass should generate a source map.

  • source_map_include_sources (Boolean)

    Whether Sass should include the sources in the generated source map.

  • style (Symbol)

    The OutputStyle of the compiled CSS.

  • functions (Hash<String, Proc>)

    Additional built-in Sass functions that are available in all stylesheets.

  • importers (Array<Object>)

    Custom importers that control how Sass resolves loads from rules like @use and @import.

  • alert_ascii (Boolean)

    If this is true, the compiler will exclusively use ASCII characters in its error and warning messages. Otherwise, it may use non-ASCII Unicode characters as well.

  • alert_color (Boolean)

    If this is true, the compiler will use ANSI color escape codes in its error and warning messages. If it’s false, it won’t use these. If it’s nil, the compiler will determine whether or not to use colors depending on whether the user is using an interactive terminal.

  • fatal_deprecations (Array<String>)

    A set of deprecations to treat as fatal.

  • future_deprecations (Array<String>)

    A set of future deprecations to opt into early.

  • logger (Object)

    An object to use to handle warnings and/or debug messages from Sass.

  • quiet_deps (Boolean)

    If this option is set to true, Sass won’t print warnings that are caused by dependencies. A “dependency” is defined as any file that’s loaded through load_paths or importer. Stylesheets that are imported relative to the entrypoint are not considered dependencies.

  • silence_deprecations (Array<String>)

    A set of active deprecations to ignore.

  • verbose (Boolean)

    By default, Dart Sass will print only five instances of the same deprecation warning per compilation to avoid deluging users in console noise. If you set verbose to true, it will instead print every deprecation warning it encounters.

Returns:

Raises:

See Also:



36
37
38
# File 'lib/sass/embedded.rb', line 36

def compile_string(...)
  compiler.compile_string(...)
end

.infoString

Returns Information about the Sass implementation.

Returns:

  • (String)

    Information about the Sass implementation.

See Also:



44
45
46
# File 'lib/sass/embedded.rb', line 44

def info
  compiler.info
end