GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dart-community/sass_builder: Transpile sass files using "build_runner" for webdev and jaspr-based apps.

BranchesTags
Open more actions menu

Latest commit

 

History

104 Commits
104 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
example
example
 
 
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
analysis_options.yaml
analysis_options.yaml
 
 
build.yaml
build.yaml
 
 
pubspec.yaml
pubspec.yaml
 
 

Repository files navigation

Build status

package:sass_builder transpiles Sass files using the build package and the Dart implementation of Sass.

Installation

This package integrates into Dart's build system, so it works after being added as a dev-dependency:

dart pub add dev:build_runner dev:sass_builder

Next, create say a web/main.scss containing the following code:

.a {
  color: blue;
}

Run dart run build_runner build to make this package emit web/main.css.

Usage

package:sass_builder mostly works how you'd expect Sass to behave in other build systems:

  • Each .scss and .sass file gets compiled to a .css file.
  • For development builds, generated CSS is expanded. For --release builds, it's emitted in a compressed form.
  • The builder will not run on input files starting with an underscore. These files can still be @use-imported into other Sass files though.

Options

To configure options for the builder see the build_config README.

  • outputStyle: Supports expanded or compressed. Defaults to expanded in dev mode, and compressed in release mode.
  • sourceMaps: Whether to emit source maps for compiled CSS. Defaults to true in development mode and to false in release mode.
  • silenceDeprecations, futureDeprecations and fatalDeprecations control how Sass handles deprecation warnings.

Example:

targets:
  $default:
    builders:
      sass_builder:
        options:
          # Emit compressed outputs in both dev and release mode.
          outputStyle: compressed
          silenceDeprecations:
            # Don't warn about @import rules
            - import

Including files

This package provides the builtin read-string function loading assets from the build system. It takes an asset URL as a first parameter and an optional mime type as a second.

When no type is given, it returns the contents of the given asset as a string. With a mime type, it returns a data: URL:

div::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  background-image: url(read-string('asset:my_pkg/web/dart.svg', 'image/svg+xml'));
  background-size: contain;
  background-repeat: no-repeat;
}

Sass dependencies

If you want to use any packages that provide source sass files, add them as normal pub dependencies. For example, if you want to use styles from package:bootstrap_sass:

dart pub add bootstrap_sass

Then, adapt web/main.scss to contain:

@use "sub";
@use "package:bootstrap_sass/scss/variables" as bootstrap;

.a {
  color: blue;
}

.c {
  color: bootstrap.$body-color;
}

Create web/_sub.scss containing the following code:

.b {
  color: red;
}

Create web/index.html containing the following code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sample</title>
    <link rel="stylesheet" href="main.css">
</head>
<body>
<div class="a">Some Text</div>
<div class="b">Some Text</div>
<div class="c">Some Text</div>
</body>
</html>

Run dart run build_runner serve and then go to localhost:8080 with a browser and check if the file web/main.css was generated containing:

.b {
  color: red;
}

.a {
  color: blue;
}

.c {
  color: #373a3c;
}

About

Transpile sass files using "build_runner" for webdev and jaspr-based apps.

pub.dev/packages/sass_builder

Topics

build-runnersasswebdev

Resources

Readme
MIT license
Activity
Custom properties

Stars

29 stars

Watchers

4 watching

Forks

23 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.