Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion css-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ define(['require', './normalize'], function(req, normalize) {
}
var csslen = css.length;
try {
css = csso.justDoIt(css);
if (typeof csso.minify === 'function') {
css = csso.minify(css).css;

@alundiak alundiak Feb 1, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, csso v2.3.1 has minify() function output result in this form:

result = debugOutput('translate', options, Date.now(), {
            css: translate(compressResult.ast),
            map: null
        });

Need to test require.css for 2 possible ways: minify(css) and minify(css).css

@alundiak alundiak Feb 18, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this code changes in regards to csso versions: 1.8.0, 2.0.0 and 2.3.1. And suggested code not always works correctly.

Suggested code (csso.minify(css).css) will cause error in case of usage csso v1.8.0

Error: TypeError: Cannot read property 'length' of undefined
    at compress (eval at <anonymous> (/usr/local/lib/node_modules/requirejs/bin/r.js:25271:33), <anonymous>:50:63)

Note: tested with requirejs v 2.1.10 (as bundled in require-css) and 2.3.2 (as latest)

So we need to improve code a bit, so that to support at least 3 major versions.

I will provide a comment a bit later, or create my own PR.

} else {
css = csso.justDoIt(css);
}
}
catch(e) {
console.log('Compression failed due to a CSS syntax error.');
Expand Down