请帮助我没有收到任何错误,但此代码不会从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"
}
}
答案 0 :(得分:1)
你的语法似乎有一个拼写错误。
更改
return gulp.src(scss + '{style.scss,rtl.scss')
要
return gulp.src(scss + '{style.scss,rtl.scss}')