Giter Site home page Giter Site logo

ionic-team / stencil-sass Goto Github PK

View Code? Open in Web Editor NEW
76.0 12.0 24.0 1.69 MB

Sass plugin for Stencil

Home Page: https://www.npmjs.com/package/@stencil/sass

License: Other

TypeScript 84.15% JavaScript 15.85%
sass scss stenciljs plugin stencil node-sass

stencil-sass's Introduction

@stencil/sass

This package is used to easily precompile Sass files within Stencil components. Internally this plugin uses a pure JavaScript implementation of Sass. Please see the Behavioral Differences from Ruby Sass doc if issues have surfaced since upgrading from previous versions which used used the node-sass implementation.

First, npm install within the project:

npm install @stencil/sass --save-dev

Next, within the project's stencil config, import the plugin and add it to the config's plugins property:

stencil.config.ts

import { Config } from '@stencil/core';
import { sass } from '@stencil/sass';

export const config: Config = {
  plugins: [
    sass()
  ]
};

During development, this plugin will kick-in for .scss or .sass style urls, and precompile them to CSS.

Options

Sass options can be passed to the plugin within the stencil config, which are used directly by sass. Please reference sass documentation for all available options. Note that this plugin automatically adds the component's directory to the includePaths array.

Inject Globals Sass Paths

The injectGlobalPaths config is an array of paths that automatically get added as @import declarations to all components. This can be useful to inject Sass variables, mixins and functions to override defaults of external collections. For example, apps can override default Sass variables of Ionic components. Relative paths within injectGlobalPaths should be relative to the stencil config file.

exports.config = {
  plugins: [
    sass({
      injectGlobalPaths: [
        'src/globals/variables.scss',
        'src/globals/mixins.scss'
      ]
    })
  ]
};

Note that each of these files are always added to each component, so in most cases they shouldn't contain CSS because it'll get duplicated in each component. Instead, injectGlobalPaths should only be used for Sass variables, mixins and functions, but does not contain any CSS.

Related

Contributing

Please see our Contributor Code of Conduct for information on our rules of conduct.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.