postcss-scss-import-dedup

1.0.4 • Public • Published

postcss-scss-import-dedup

PostCSS plugin to remove duplicate @import statements.

Installation

With yarn

$ yarn add postcss-scss-import-dedup

Or npm:

$ npm install --save postcss-scss-import-dedup

Usage

const fs = require('fs'),
    postcss = require('postcss'),
    syntax = require('postcss-scss'),
    dedupImports = require('postcss-scss-import-dedup')
    
const scss = fs.readFileSync('scss/input.scss', 'utf-8')
    
postcss([dedupImports()]).process(scss, {
  syntax: syntax,
  from: 'scss/input.scss',
})

scss/input.scss:

@import 'a';
@import 'b';
@import 'a';

Will give you:

@import 'a';
@import 'b';

Options


opts.filter

A function that receives a an import string and determines if it should be tracked by the deduper. This can be used as an escape valve while using this plugin.

Default:

null

Example:

dedupImports({
    filter: importpath => {
        return importpath == 'a'
    }
})

Will dedup only @import 'a' statements.

For more information see the scss-extractor documentation.

Package Sidebar

Install

npm i postcss-scss-import-dedup

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

3.12 kB

Total Files

4

Last publish

Collaborators

  • christophersmith262