question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PostCSS does not honor options passed to Autoprefixer

See original GitHub issue
  • Laravel Mix Version: 1.5.1
  • Node Version: 8.5.0
  • NPM Version: 5.4.2
  • OS: OS X El Capitan v10.11.5

Description:

Attempting to pass custom options to Autoprefixer through the postCss array appears to do nothing.

Custom options may be necessary when dealing with cross-device / cross-browser QA on common frontend frameworks like Bootstrap.

Steps To Reproduce:

package.json

{
  "private": true,
  "scripts": {
    "dev": "./node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "bootstrap": "^4.0.0-alpha.6",
    "laravel-mix": "^1.0"
  }
}

webpack.mix.js

let mix = require('laravel-mix');

mix.sass('assets/scss/main.scss', 'public/css');
mix.sass('assets/scss/main2.scss', 'public/css').options({
    postCss: [
        require('autoprefixer')({
            browsers: [
                'last 2 versions',
                'iOS >= 8',
                'Safari >= 8',
            ],
            cascade: false,
            flexbox: "no-2009"
        }),
    ]
});

assets/main.scss

@import '~bootstrap/scss/bootstrap';

assets/main2.scss

@import '~bootstrap/scss/bootstrap';

Then run npm run dev.

Note that the output of public/css/main.css and public/css/main2.css are identical.

Hardcoding in some options on line 160 of /src/builder/webpack-rules.js will yield the desired results. Differences can be found by turning off one of the sass tasks and running the build with hardcoded options in place:

plugins.push(require('autoprefixer')({
    browsers: [
        'last 2 versions',
        'iOS >= 8',
        'Safari >= 8',
    ],
    cascade: false,
    flexbox: "no-2009"
}));

Is there something I could be missing? Is there a place I can pass in Autoprefixer options without altering source code?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
exfriendcommented, Jan 23, 2018

Thanks @AndreasElia and great job @JeffreyWay !

1reaction
andreaseliacommented, Jan 10, 2018

@maiorano84 did you solve this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

PostCSS does not honor options passed to Autoprefixer #1289
Attempting to pass custom options to Autoprefixer through the postCss array appears to do nothing. Custom options may be necessary when dealing ...
Read more >
Using autoprefixer with postcss in webpack 2.x - Stack Overflow
Now you can pass options directly to the loader declaration. const autoprefixer = require('autoprefixer'); let settings = { /*...*/ ...
Read more >
postcss-cli-simple - npm
Plugin options can be specified using yargs dot notation. For example, to pass browsers option to autoprefixer one can use --autoprefixer.
Read more >
PostCSS API
Passes all declaration values within the container that match pattern through callback, replacing those values with the returned result of callback. This method ......
Read more >
What is PostCSS? How to Use Plugins to Automate CSS Tasks
PostCSS is a Node.js tool that transforms your styles using JavaScript plugins. It generates more downloads per week on NPM than other CSS ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found