简体   繁体   English

gulp-cssmin TypeError无法读取null的属性“ 0”

[英]gulp-cssmin TypeError cannot read property '0' of null

I'm trying to minify my code . 我正在尝试最小化我的代码。 but t have this issue 但是没有这个问题

D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\selectors\extractor.js:66
  return name.replace(/^\-\w+\-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase();
                                                          ^

TypeError: Cannot read property '0' of null
    at findNameRoot (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\selectors\extractor.js:66:59)
    at extract (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\selectors\extractor.js:36:9)
    at restructure (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\selectors\restructure.js:297:22)
    at optimize (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\selectors\advanced.js:71:5)
    at minify (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\clean.js:228:5)
    at whenSourceMapReady (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\clean.js:135:7)
    at Object.whenDone (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\clean.js:155:14)
    at processNext (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\imports\inliner.js:105:13)
    at importFrom (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\imports\inliner.js:79:10)
    at processNext (D:\gulp-compiler\node_modules\gulp-cssmin\node_modules\clean-css\lib\imports\inliner.js:104:16)

i try search for my issue but no new my gulp js is // copy css and minify from development to deployment 我尝试搜索我的问题,但没有新的gulp js //复制CSS并从开发到部署最小化

gulp.task("compress-css", () => {
  return gulp.src( pathGo+"css/**/*.css")
   .pipe(cssmin().on('error',function(e){
        console.log(e)
  })) 
  .pipe(gulp.dest('testing_folder/css1'));;
});

notice i used proxy 通知我使用代理

i find the issue that css file is't writing correctly ( Files ready from framework ,the framework can work with this files ). 我发现css文件无法正确写入的问题(文件已从框架准备就绪,框架可以与此文件一起使用)。 i try move my files away from framework css files and run gulp so gulp is running and minify correctly thanks for all 我尝试将文件从框架css文件中移开并运行gulp,以便gulp正在运行并正确缩小,感谢所有
I wish my answer help you if the same issue faced you 如果遇到同样的问题,希望我的回答对您有所帮助

I encountered the same problem, the final discovery is that I quote the font file syntax error. 我遇到了同样的问题,最后的发现是我引用了字体文件语法错误。

before 之前

@import url(../font/PingFangSC.ttf);

after

@font-face {
font-family: 'PingFang SC';
src: url('../font/PingFangSC.ttf');
font-weight: normal;
font-style: normal;}

why CSS not provide syntax for compilation checks? 为什么CSS不提供编译检查的语法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM