运行gulp sass时
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require('gulp-notify');
var minifycss = require('gulp-minify-css');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
/* Setup scss path */
var paths = {
scss: './assets/sass/*.scss'
};
/* Sass task */
gulp.task('sass', function () {
gulp.src('assets/scss/main.scss')
.pipe(plumber())
.pipe(sass({
includePaths: ['scss'].concat(neat)
}))
.pipe(gulp.dest('assets/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('assets/css'))
/* Reload the browser CSS after every change */
.pipe(reload({stream:true}));
});
我收到错误“ ReferenceError:未定义整洁”。由于“整洁”未定义变量。应该将其替换。
非常感谢您的帮助。
答案 0 :(得分:0)
includePaths:['scss']。concat(整洁)
您在哪里定义了整型变量?
答案 1 :(得分:0)
var neat = require('node-neat')。includePaths;
然后
includePaths:['styles']。concat(neat)
答案 2 :(得分:0)
也许
var neat = require('node-neat')。includePaths;
然后
includePaths:['styles']。concat(neat)
??
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function () {
gulp.src('path/to/input.scss')
.pipe(sass({
// includePaths: require('node-neat').with('other/path', 'another/path')
// - or -
includePaths: require('node-neat').includePaths
}))
.pipe(gulp.dest('path/to/output.css'));
});
https://github.com/sass/node-sass上的文档
说
includePaths
Type: Array<String> Default: []
LibSass可以尝试尝试解决的一系列路径 @import声明。使用数据时,建议您使用 这个。
所以这个谁可以工作?
var path = require('path');
gulp.task('sass', function () {
gulp.src('assets/scss/main.scss')
.pipe(plumber())
.pipe(sass({
includePaths: [path.resolve('./assets/sass')]
}))
.pipe(gulp.dest('assets/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('assets/css'))
/* Reload the browser CSS after every change */
.pipe(reload({stream:true}));
});