请帮助我没有任何错误, 但是此代码不会从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你的语法似乎有错字。
【Gulp没有错误,但SASS没有编译成CSS】更改
return gulp.src(scss + '{style.scss, rtl.scss')
To
return gulp.src(scss + '{style.scss, rtl.scss}')
推荐阅读
- 通过自定义分类将Woocommerce产品按类别分组
- WP重力表添加无显示
- Google Chrome本地主机错误NET::ERR_CERT_AUTHORITY_INVALID,但没有关闭选项
- 为WordPress自定义页面模板赋予外观编辑器标题
- Wordpess模板中特色图像下方的鬼空白
- 从单个帖子中获取WordPress类别
- 获取作为小部件放置在WordPress中我的页脚区域中的图像的URL
- 从WordPress高级自定义字段数组中获取正确的图片网址()
- #yyds干货盘点#使用HTTPS加密网页数据