Detalhes do pacote

@csstools/postcss-sass

jonathantneal161.1kCC0-1.05.1.1

Use Sass as a PostCSS plugin

postcss, css, postcss-plugin, sass

readme (leia-me)

PostCSS Sass PostCSS Logo

NPM Version test Discord

PostCSS Sass lets you use Sass as a PostCSS plugin.

$font-stack:    Helvetica, sans-serif;
$primary-color: #333;

:root {
  color: $primary-color;
  font: 100% $font-stack;
}

/* becomes */

:root {
  color: #333;
  font: 100% Helvetica, sans-serif;
}

PostCSS Sass uses dart-sass, letting you safely run transforms before and after Sass, watching for changes to Sass imports, and preserving source maps.

Usage

Add PostCSS Sass to your build tool:

npm install postcss @csstools/postcss-sass --save-dev

Node

Use PostCSS Sass to process your CSS:

require('@csstools/postcss-sass').process(YOUR_CSS);

PostCSS

Use PostCSS Sass as a plugin:

postcss([
  require('@csstools/postcss-sass')(/* dart-sass options */)
]).process(YOUR_CSS);

The standard CSS parser included with PostCSS may not be able to parse SCSS specific features like inline comments. To accurately parse SCSS, use the SCSS Parser.

npm install postcss-scss --save-dev
const postcss = require('postcss');
const postcssSass = require('@csstools/postcss-sass');

postcss([
  postcssSass(/* pluginOptions */)
]).process(YOUR_CSS, {
  syntax: require('postcss-scss')
});

Gulp

Add Gulp PostCSS to your build tool:

npm install gulp-postcss --save-dev

Use PostCSS Sass in your Gulpfile:

var postcss = require('gulp-postcss');

gulp.task('css', function () {
  return gulp.src('./src/*.css').pipe(
    postcss([
      require('@csstools/postcss-sass')(/* dart-sass options */)
    ])
  ).pipe(
    gulp.dest('.')
  );
});

Grunt

Add Grunt PostCSS to your build tool:

npm install grunt-postcss --save-dev

Use PostCSS Sass in your Gruntfile:

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
  postcss: {
    options: {
      use: [
        require('@csstools/postcss-sass')(/* dart-sass options */)
      ]
    },
    dist: {
      src: '*.css'
    }
  }
});

Options

PostCSS Sass options are directly forwarded to dart-sass options.

changelog (log de mudanças)

Changes to PostCSS Sass

5.1.1 (December 28, 2023)

  • Make PostCSS dependency messages more consistent.

5.1.0 (December 28, 2023)

  • Updated: dart-sass to 1.69.5 (minor)
  • Updated: source-map to 0.7.4 (patch)

5.0.1 (March 8, 2022)

  • Fixes an issue with import files not being sent for processors to pick up. #31

5.0.0 (February 14, 2022)

  • Updated to support PostCSS 8 (breaking)

4.0.0 (January 23, 2018)

  • Replaced: node-sass with dart-sass
  • Updated: postcss to 7.0.14 (patch)

3.0.0 (October 4, 2018)

  • Fixed: issue with sourcemaps 0.7.x returning a Promise instead of an Object
  • Updated: node-sass to 4.9.3 (minor)
  • Updated: postcss to 7.0.5 (major)
  • Updated: source-map to 0.7.3 (major for this project)

2.0.0 (December 25, 2017)

  • Added: custom source-map implemention with fix for sass/libsass#2312
  • Changed: index.mjs module for index.js module
  • Changed: merge-source-map dependency for custom source-map implemention
  • Changed: first plugin detection for custom source-map implemention

1.0.0 (November 2, 2017)

  • Initial version