首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gulp、postcss和UnCSS

Gulp、postcss和UnCSS
EN

Stack Overflow用户
提问于 2018-07-27 12:31:52
回答 1查看 1.9K关注 0票数 1

我试图清理我的css,并使用UnCSS与gulp和Postcss。

我有这个:

代码语言:javascript
复制
gulp.task('optim-css', function() {
    var stream1 = gulp.src(['dev/css/bootstrap.min.css','dev/css/custom.css'])
        .pipe(postcss([ rucksack() ]))
        .pipe(postcss(uncss({
                html:   ['http://localhost/olssonseder/','http://localhost/olssonseder/lyssna/','http://localhost/olssonseder/repertoar/','http://localhost/olssonseder/kontakta/','http://localhost/olssonseder/kontakta/','http://localhost/olssonseder/om-gitarren/'],
                ignore: [new RegExp('.b-lazy*'),
                         new RegExp('.stickyFooter')]
            }))
        );

    var stream2 = gulp.src(['dev/css/responsive-nav.css','dev/css/lity.css','dev/css/mp3-player-button.css'])

    return merge(stream1, stream2)
        .pipe(concat('styles.css'))
        .pipe(cleanCSS())
        .pipe(gulp.dest(''))
        .pipe(browserSync.stream());
});

但我得到了这个错误,我只是不知道为什么:

代码语言:javascript
复制
[14:21:49] TypeError: UnCSS: expected a callback
    at init (C:\Users\Nicke\Documents\PortableApps\UwAmp\www\olssonseder\wp-content\themes\bastema\node_modules\uncss\src\uncss.js:176:15)
    at Gulp.<anonymous> (C:\Users\Nicke\Documents\PortableApps\UwAmp\www\olssonseder\wp-content\themes\bastema\gulpfile.js:48:23)
    at module.exports (C:\Users\Nicke\Documents\PortableApps\UwAmp\www\olssonseder\wp-content\themes\bastema\node_modules\orchestrator\lib\runTask.js:34:7)
    at Gulp.Orchestrator._runTask (C:\Users\Nicke\Documents\PortableApps\UwAmp\www\olssonseder\wp-content\themes\bastema\node_modules\orchestrator\index.js:273:3)
    at Gulp.Orchestrator._runStep (C:\Users\Nicke\Documents\PortableApps\UwAmp\www\olssonseder\wp-content\themes\bastema\node_modules\orchestrator\index.js:214:10)
    at Gulp.Orchestrator.start (C:\Users\Nicke\Documents\PortableApps\UwAmp\www\olssonseder\wp-content\themes\bastema\node_modules\orchestrator\index.js:134:8)
    at C:\Users\Nicke\Documents\PortableApps\UwAmp\www\olssonseder\wp-content\themes\bastema\node_modules\gulp\bin\gulp.js:129:20
    at process._tickCallback (internal/process/next_tick.js:150:11)
    at Function.Module.runMain (module.js:703:11)
    at startup (bootstrap_node.js:190:16)
[14:21:52] Finished 'optim-js' after 2.75 s
[14:21:52] Finished 'optim-deferjs' after 2.73 s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bastema@1.0.0 gi: `gulp init`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bastema@1.0.0 gi script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nicke\AppData\Roaming\npm-cache\_logs\2018-07-27T12_21_52_508Z-debug.log

有人知道为什么会发生这种事吗?

EN

回答 1

Stack Overflow用户

发布于 2018-08-08 20:15:59

我也遇到了同样的问题。在创建回调并遇到其他问题后,我发现uncss不能直接与postcss一起使用。使用postcss-uncss代替,它的工作,如预期。

来自:https://github.com/uncss/uncss

注意:根据您的环境,您可能无法将uncss用作PostCSS插件,因为插件不是直接导出的。在这种情况下,使用包装库postcss-uncss。

下面是postcss-uncss库:https://github.com/uncss/postcss-uncss

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51558009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档