【问题标题】:Autoprefixer in laravel mixlaravel mix 中的自动前缀
【发布时间】:2018-07-19 19:51:45
【问题描述】:

Laravel mix 没有编译自动前缀。 output.css 与 input.css 相同
- webpack.mix.js

let mix = require('laravel-mix');
mix.styles('resources/css/input.css', 'public/css/output.css')
    .options({
        postCss: [
            require('autoprefixer')({
                browsers: ['last 40 versions'],
            })
        ]
    });

- 输入.css

.example {
    display: grid;
    transition: all .5s;
    user-select: none;
    background: linear-gradient(to bottom, white, black);
}

- 输出.css

.example {
    display: grid;
    transition: all .5s;
    user-select: none;
    background: linear-gradient(to bottom, white, black);
}
  • Laravel 5.4 版
  • laravel-mix 1.0

如何启用自动前缀?

【问题讨论】:

    标签: css laravel webpack gulp laravel-mix


    【解决方案1】:

    我找不到关于 mix.styles() 函数的任何文档。 但是如果你只是想通过 postCss 运行你的样式表,你可以这样做:

    mix.postCss('resources/css/input.css', 'public/css/output.css', [
        require('autoprefixer')({
            browsers: ['last 40 versions'],
            grid: true
        })
    ])
    

    将输出:

    .example {
        display: -ms-grid;
        display: grid;
        -webkit-transition: all 0.5s;
        transition: all 0.5s;
        -webkit-user-select: none;
           -moz-user-select: none;
            -ms-user-select: none;
                user-select: none;
        background: -webkit-gradient(linear, left top, left bottom, from(white), to(black));
        background: -webkit-linear-gradient(top, white, black);
        background: -o-linear-gradient(top, white, black);
        background: linear-gradient(to bottom, white, black);
    }
    

    【讨论】:

    • 谢谢。这是有效的。可以将多个文件混合为单个文件
    • 是的,只需在上面的示例中添加一个@import,然后 mix 就会将它们组合起来。或者使用 mix.combine()。或者使用 mix.sass() 和 .scss 或 .sass
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-07
    • 1970-01-01
    • 2018-07-26
    • 1970-01-01
    • 2018-03-14
    • 2020-07-20
    • 1970-01-01
    相关资源
    最近更新 更多