我在缩小一些scss时遇到了一个吞咽问题。
我刚刚修改了我的文件从非常旧的代码,但我遇到了一个错误与编译scss。
我正在运行gulp bundleSass
并收到一个错误:
TypeError: Cannot read property 'isNull' of undefined
at DestroyableTransform._transform (C:\xampp\htdocs\...\node_modules\gulp-clean-css\index.js:15:14)
at DestroyableTransform.Transform._read (C:\...\node_modules\readable-stream\lib\_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (C:\xampp\htdocs\...\node_modules\readable-stream\lib\_stream_transform.js:172:83)
at doWrite (C:\xampp\htdocs\...\node_modules\readable-stream\lib\_stream_writable.js:428:64)
at writeOrBuffer (C:\xampp\htdocs\node_modules\readable-stream\lib\_stream_writable.js:417:5)
at DestroyableTransform.Writable.write (C:\xampp\htdocs\...\node_modules\readable-stream\lib\_stream_writable.js:334:11)
at bundleSass (C:\xampp\htdocs\...\gulpfile.js:21:21)
at bundleSass (C:\xampp\htdocs\...\node_modules\undertaker\lib\set-task.js:13:15)
at bound (domain.js:427:14)
at runBound (domain.js:440:12)
这是我的gulpfile.js
const {src, dest, watch} = require('gulp');
const minifyJs = require('gulp-uglify');
const minifySass = require('gulp-sass');
const minifyCss = require('gulp-clean-css');
const sourceMaps = require('gulp-sourcemaps');
const concat = require('gulp-concat');
const bundleCss = () => {
return src('./assets/vendor/**/*.css')
.pipe(sourceMaps.init())
.pipe(minifyCss())
.pipe(concat('bundle.min.css'))
.pipe(sourceMaps.write())
.pipe(dest('./dist/css/'));
};
const bundleSass = () => {
return src('./assets/styles/*.scss')
.pipe(sourceMaps.init())
.pipe(minifySass().on('error', minifySass.logError))
.pipe(minifyCss().write())
.pipe(sourceMaps.write())
.pipe(concat('main.min.css'))
.pipe(dest('/dist/css/'));
};
const bundleJs = () => {
return src('./assets/vendor/**/*.js')
.pipe(sourceMaps.init())
.pipe(minifyJs())
.pipe(concat('bundle.min.js'))
.pipe(sourceMaps.write())
.pipe(dest('./dist/js/'));
};
const devWatch = () => {
watch('./assets/vendor/**/*.js', bundleJs)
watch('./assets/vendor/**/*.css', bundleCss)
watch('./assets/styles/*.scss', bundleSass)
};
exports.bundleCss = bundleCss;
exports.bundleSass = bundleSass;
exports.bundleJs = bundleJs;
exports.devWatch = devWatch;
有人知道为什么会出错吗?bundleCss
不知道。
1条答案
按热度按时间e4yzc0pl1#
以下是正确的gulpfile及其修复程序: