简体   繁体   English

Grunt PostCSS编译非常慢

[英]Grunt PostCSS compilation very slow

I'm giving postCSS a go by pure curiosity but I'm having a compilation time around ~2sec already. 出于好奇,我给了postCSS一个机会,但是我已经有大约2秒的编译时间。

I'm only using 3 plugins : autoprefixer , postcss-import and postcss-nested 我只使用3个插件: autoprefixerpostcss-importpostcss-nested

I've got app.css that imports 2 files : 我有导入2个文件的app.css

@import "_base/_base.css";

@import "_common/_common.css";

then I have _base.css : 然后我有_base.css

.title {
    display: flex;
    color: white;
}

and _common.css : _common.css

header {
    background: red;

    h1 {
        background: black;
    }
}

My watcher is only watching /postCSS : 我的观察者仅在观看/postCSS

    ...
    watch: {
        postcss: {
            files: grunt.settings.devDir + 'postCSS/{,**/}*.css',
            tasks: ['postcss:dev']
        }
    },
    ...

postcss:dev task: postcss:dev任务:

        dev: {
            options: {
                map: false,
                processors: [
                    require('autoprefixer')({browsers: 'last 1 versions'}),
                    require('postcss-import')(),
                    require('postcss-nested')()
                ]
            },
            files: [{
                expand: true,
                cwd: grunt.settings.devDir + 'postCSS/',
                src: ['app.css'],
                dest: grunt.settings.devDir + 'css/'
            }]
        },

So my question is, how can I already get 2 seconds to compile 3 small css files ? 所以我的问题是,我如何才能花2秒的时间来编译3个小的CSS文件? Am I missing something ? 我想念什么吗?

Thanks! 谢谢!

Now, PostCSS has this problem, it's too slow. 现在,PostCSS出现了这个问题,它太慢了。

In this article, the author replicates the workflow with PostCSS and without PostCSS. 文章中,笔者复制与PostCSS和不PostCSS工作流程。 The final results give you the idea of PostCSS has lot of potential, but you should change your working tasks with the CSSNext version. 最终结果使您认为PostCSS具有很大的潜力,但是您应该使用CSSNext版本更改工作任务。

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

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