0

Im trying to use gulp-uncss with all my js and css files. Only with the css files works fines, the problem is that my application.js has this structure:

"use strict";

(function () {})();

It seems that uncss doesn't recognize this line as js syntax and throw an error. How can I avoid this issue or only this line? Thank u!

This is the error I see on my console:

/Users/noeliabelenlopez/Documents/frontend-bootstrap/node_modules/gulp-uncss/node_modules/uncss/node_modules/bluebird/js/release/async.js:48
    fn = function () { throw arg; };
                       ^
CssSyntaxError: uncss/node_modules/css: unable to parse undefined:
<css input>:4:44: Unknown word
        1:        "use strict";
        2:
        3:        (function () {})();
        4:     -> sourceMappingURL=data:application/json;b
        5:

1 Answers1

0

uncss can't process JS. It only processes CSS & HTML.

If you have dynamically added classes, you need to use the ignore option to prevent their removal.

If you have an single-page-app, https://github.com/purifycss/purifycss might work better. It is not as efficient as uncss for sites that are mostly HTML, but uncss doesn't work for JS-heavy sites.

RyanZim
  • 6,609
  • 1
  • 27
  • 43