gulp-sass-import-once
v2.0.2
Published
Recursively removes duplicate imports accross Sass files.
Downloads
27
Maintainers
Readme
gulp-sass-import-once
Gulp plugin for gulp-sass to remove duplicate imports.
Install
npm install gulp-sass-import-once --save-dev
Basic Usage
main.scss
@import "path/to/foo.scss";
@import "path/to/bar.scss";
foo.scss
.foo { background: red; }
bar.scss
@import "foo.scss";
.bar { background: blue; }
NOTE: Also support using
'
(single quotes) for example:@import 'path/to/foo.scss';
gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var sassImportOnce = require('gulp-sass-import-once');
gulp.task('styles', function () {
return gulp
.src('src/styles/main.scss')
.pipe(sassImportOnce())
.pipe(sass())
.pipe(gulp.dest('dist/styles'));
});
dist/styles/main.css
.foo { background: red; }
.bar { background: blue; }
Additional import paths
You can optionally provide an array of paths to search for files to import.
gulp.task('styles', function () {
return gulp
.src('src/styles/main.scss')
.pipe(sassImportOnce({
importPaths: [
'node_modules',
'vendor'
]
}))
.pipe(sass())
.pipe(gulp.dest('dist/styles'));
});
Contribute
Issues and PRs are much appreciated.
Run tests
npm test
Build dist
npm run compile