gulp sass 没有编译我的 .min 文件,但没有抛出任何错误
gulp sass is not compiling my .min file, yet no errors are thrown
gulp 的新手,一切都已安装并且运行正常
gulp --版本
命令行版本:2.3.0
本地版本:4.0.2
当我更改我的 scss 文件时,什么也没有发生。gulp 在终端 运行 中很高兴
[13:34:16] Starting 'compile_scss'...
[13:34:16] Starting 'compile_scss'...
[13:34:16] Finished 'compile_scss' after 12 ms
[13:34:16] Starting 'detect_change_scss'...
[13:34:16] Finished 'detect_change_scss' after 16 ms
[13:34:16] Finished 'compile_scss' after 32 ms*
这是我的代码
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var renamed = require('gulp-rename');
var changed = require('gulp-changed');
var SCSS_SRC = './src/Assets/scss/**/*.scss';
var SCSS_DEST = './src/Assets/css';
function compile_scss (done) {
gulp.src(SCSS_SRC)
.pipe(sass().on('error', sass.logError))
.pipe(minifyCSS())
.pipe(renamed({ suffix: '.min' }))
.pipe(changed(SCSS_DEST))
.pipe(gulp.dest(SCSS_DEST));
done();
}
function detect_change_scss (done) {
gulp.watch(SCSS_SRC)
done();
}
gulp.task("compile_scss", gulp.series(compile_scss, detect_change_scss, ));
您需要告诉 gulp 在检测到更改时要 运行 哪个函数。所以试试这个:
function detect_change_scss (done) {
gulp.watch(SCSS_SRC, gulp.series(compile_scss))
done();
}
gulp 的新手,一切都已安装并且运行正常
gulp --版本 命令行版本:2.3.0 本地版本:4.0.2
当我更改我的 scss 文件时,什么也没有发生。gulp 在终端 运行 中很高兴
[13:34:16] Starting 'compile_scss'...
[13:34:16] Starting 'compile_scss'...
[13:34:16] Finished 'compile_scss' after 12 ms
[13:34:16] Starting 'detect_change_scss'...
[13:34:16] Finished 'detect_change_scss' after 16 ms
[13:34:16] Finished 'compile_scss' after 32 ms*
这是我的代码
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var renamed = require('gulp-rename');
var changed = require('gulp-changed');
var SCSS_SRC = './src/Assets/scss/**/*.scss';
var SCSS_DEST = './src/Assets/css';
function compile_scss (done) {
gulp.src(SCSS_SRC)
.pipe(sass().on('error', sass.logError))
.pipe(minifyCSS())
.pipe(renamed({ suffix: '.min' }))
.pipe(changed(SCSS_DEST))
.pipe(gulp.dest(SCSS_DEST));
done();
}
function detect_change_scss (done) {
gulp.watch(SCSS_SRC)
done();
}
gulp.task("compile_scss", gulp.series(compile_scss, detect_change_scss, ));
您需要告诉 gulp 在检测到更改时要 运行 哪个函数。所以试试这个:
function detect_change_scss (done) {
gulp.watch(SCSS_SRC, gulp.series(compile_scss))
done();
}