ben-eb / gulp-csso

Minify CSS with CSSO.
MIT License
243 stars 26 forks source link

Reproducible bug - multiple args to not breaks: &:not(.list, .custom) #10

Closed michaelBenin closed 9 years ago

michaelBenin commented 9 years ago

Hey this is my gulp config:

gulp.task(`${targetName}-styles-prod`, () => {
        let targetProps = config.styles[targetName];
        let { cssDest, stylesSrc, sassConf, autoprefixerBrowsers } = targetProps;
        return gulp.src(stylesSrc)
            .pipe(sourcemaps.init())
            .pipe(sass(sassConf).on('error', sass.logError))
            .pipe(autoprefixer(autoprefixerBrowsers))
            .pipe(csso())
            .pipe(gulp.dest(cssDest));
    });

Error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: no writecb in Transform class
    at afterTransform (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:95:33)
    at Object.TransformState.afterTransform (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
    at Object.immediate._onImmediate (timers.js:348:16)
    at processImmediate [as _immediateCallback] (timers.js:330:15)

The fix was to change:

 &:not(.list, .custom) {
      padding-left: 30px;
      padding-right: 30px;
    }

To:

    &:not(.list) {
      padding-left: 30px;
      padding-right: 30px;
    }

    &:not(.custom) {
      padding-left: 30px;
      padding-right: 30px;
    }
ben-eb commented 9 years ago

Looks like your error is with the gulp-autoprefixer package, not this one. :smile:

at afterTransform (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-autoprefixer/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:95:33)
michaelBenin commented 9 years ago

I'm sorry but this is in cssO.

    gulp.task(`${targetName}-styles-prod`, () => {
        let targetProps = config.styles[targetName];
        let { cssDest, stylesSrc, sassConf, autoprefixerBrowsers } = targetProps;
        return gulp.src(stylesSrc)
            .pipe(sourcemaps.init())
            .pipe(sass(sassConf).on('error', sass.logError))
            //.pipe(autoprefixer(autoprefixerBrowsers))
            .pipe(csso())
            .pipe(gulp.dest(cssDest));
    });

Removed csso.

Error

[18:18:10] Starting 'all-styles-prod'...

/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:399
        throw new Error('Please check the validity of the CSS block starting f
              ^
Error: Please check the validity of the CSS block starting from the line #1077
    at throwError (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:399:15)
    at getNotFunctionBody (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1254:17)
    at getFunktion (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1213:13)
    at getPseudoc (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1710:64)
    at getPseudo (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1667:39)
    at _getSimpleSelector (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1884:43)
    at getSimpleSelector (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1871:17)
    at getSelector (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1810:58)
    at getRuleset (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1736:26)
    at getAtrulers (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:705:31)
    at getAtruler (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:663:22)
    at getAtrule (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:605:28)
    at getStylesheet (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:1937:60)
    at Object.CSSPRules.stylesheet (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:365:69)
    at _getAST (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:409:38)
    at exports.srcToCSSP (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:2287:16)
    at Object.exports.srcToCSSP (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/gonzales.cssp.node.js:2292:16)
    at exports.parse (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/cssoapi.js:7:21)
    at Object.exports.justDoIt (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/node_modules/csso/lib/cssoapi.js:21:41)
    at Transform.stream._transform (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-csso/index.js:25:34)
    at Transform._read (_stream_transform.js:179:10)
    at Transform._write (_stream_transform.js:167:12)
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at Transform.Writable.write (_stream_writable.js:180:11)
    at write (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
    at flow (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
    at DestroyableTransform.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
    at emitReadable (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
    at readableAddChunk (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)
    at DestroyableTransform.Readable.push (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:149:10)
    at DestroyableTransform.Transform.push (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:145:32)
    at afterTransform (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:101:12)
    at TransformState.afterTransform (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:79:12)
    at filePush (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/index.js:89:7)
    at Object.callback (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/index.js:123:9)
    at options.success (/Users/mbenin/Projects/redesign-slot-fastcompany/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:293:32)
Admins-MacBook-Pro:redesign-slot-fastcompany mbenin$ 

Breaks on the same above.

michaelBenin commented 9 years ago

Can you please revaluate the validity of this issue?

yongzhihuang commented 9 years ago

Can confirm, I have the same issue with csso, looks like it's unable to parse lists properly when doing it in this form

&:not(.foo, .bar)

ben-eb commented 9 years ago

Ah ok, looks like that is a duplicate of https://github.com/css/csso/issues/215. You are probably better off using either https://github.com/murphydanger/gulp-minify-css or https://github.com/ben-eb/gulp-cssnano as alternatives to csso, as it is not being maintained currently and there are many open issues.