【问题标题】:Grunt PostCSS compilation very slowGrunt PostCSS 编译很慢
【发布时间】:2018-08-29 07:20:35
【问题描述】:

我纯粹出于好奇尝试了 postCSS,但我已经有大约 2 秒的编译时间了。

我只使用了 3 个插件:autoprefixerpostcss-importpostcss-nested

我有 app.css 导入 2 个文件:

@import "_base/_base.css";

@import "_common/_common.css";

然后我有_base.css

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

_common.css

header {
    background: red;

    h1 {
        background: black;
    }
}

我的观察者只在看/postCSS

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

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/'
            }]
        },

所以我的问题是,我怎样才能有 2 秒的时间来编译 3 个小 css 文件?我错过了什么吗?

谢谢!

【问题讨论】:

    标签: javascript gruntjs postcss


    【解决方案1】:

    现在 PostCSS 有这个问题,太慢了。

    this 文章中,作者复制了使用 PostCSS 和不使用 PostCSS 的工作流程。最终结果告诉你 PostCSS 有很大的潜力,但你应该用 CSSNext 版本改变你的工作任务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-29
      • 2014-02-10
      • 1970-01-01
      • 1970-01-01
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 2015-10-06
      相关资源
      最近更新 更多