个性化阅读
专注于IT技术分析

Gulp没有错误,但SASS没有编译成CSS

请帮助我没有任何错误, 但是此代码不会从scss文件创建已编译的CSS。如果我认为不重要, 那么我将在下划线WP主题下编写代码。我的机器上装有所有依赖项。如果有人需要看到它, 我将附加我的JSON。

    var themename = 'taylerco';

var gulp = require('gulp'), //prepare and optimize code
    autoprefixer = require('autoprefixer'), browserSync = require('browser-sync').create(), image = require('gulp-image'), jshint = require('gulp-jshint'), postcss = require('gulp-postcss'), sass = require('gulp-sass'), sourcemaps = require('gulp-sourcemaps'), //only work with new or updated files
   newer = require('gulp-newer'), //name of working theme folder
   root = '../' + themename + '/', scss = root + 'sass/', js = root + 'js/', img = root + 'images/', languages = root + 'languages/';

// css via sass and autoprefixer
gulp.task('css', function(){
    return gulp.src(scss + '{style.scss, rtl.scss')
    .pipe(sourcemaps.init())
    .pipe(sass({
        outputStyle:'expanded', indentType:'tab', indentWidth:'1'
    }).on('error', sass.logError))
    .pipe(postcss([
        autoprefixer('last 2 versions', '> 1%')
    ]))
    .pipe(sourcemaps.write(scss + 'maps'))
    .pipe(gulp.dest(root));
});

//optimize images through gulp-image
gulp.task('images', function(){
    return gulp.src(img + 'RAW/**/*.(jpg, JPG, png)')
    .pipe(newer(img))
    .pipe(image())
    .pipe(gulp.dest(img));
});

//javascript
gulp.task('javascript', function(){
    return gulp.src([js + '*.js'])
    .pipe(jshint())
    .pipe(jshint.reporter('default'))
    .pipe(gulp.dest(js));

});

//watch everything
gulp.task('watch', function(){
    browserSync.init({
        open: 'external', proxy: 'localhost:8888', port: 8080
    });
    gulp.watch([root + '**/*.css', root + '**/*.scss'], ['css']);
    gulp.watch(js + '**/*.js', ['javascript']);
    gulp.watch(img + 'RAW/**/*.(jpg, JPG, png)', ['images']);
    gulp.watch(root + '**/*').on('change', browserSync.reload);
});

//default talk (runs at initiation: gulp --verbose)
gulp.task('default', ['watch']);

package.json

{
  "name": "tayler.co", "version": "1.0.0", "description": "", "main": "gulpfile.js", "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  }, "author": "", "license": "ISC", "dependencies": {
    "autoprefixer": "^7.1.6", "browser-sync": "^2.18.13", "gulp": "^3.9.1", "gulp-image": "^4.1.0", "gulp-jshint": "^2.0.4", "gulp-newer": "^1.3.0", "gulp-postcss": "^7.0.0", "gulp-sass": "^3.1.0", "gulp-sourcemaps": "^2.6.1", "jshint": "^2.9.5"
  }
}

#1


你的语法似乎有错字。

更改

 return gulp.src(scss + '{style.scss, rtl.scss')

To

 return gulp.src(scss + '{style.scss, rtl.scss}')
赞(0)
未经允许不得转载:srcmini » Gulp没有错误,但SASS没有编译成CSS

评论 抢沙发

评论前必须登录!