Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

laravel-mixでvueにカスタムなPostCSS設定を使う

TL;DR

mix.jsなどではなく、mix.options.postCssに設定する

設定例( postcss-custom-mediaの例 )

mix.options({
  postCss: [
    require("postcss-custom-media")({
      "extensions": {
          '--phone': '(min-width: 544px)',
          '--tablet': '(min-width: 768px)',
          '--desktop': '(min-width: 992px)',
      }
    })
  ]
})

詳しく

laravel-mixのvueにおいて、postcss.config.jsを配置しても.vueのファイルには利用されずにうまく行かなった。

コードを深追いしてみると、mix.options.postCssを設定すれば効かせてくれるとわかった。
https://github.com/JeffreyWay/laravel-mix/blob/d0951a8f91feef2ff0d1dd4e8aba125c5aadf394/src/builder/webpack-rules.js#L252

Autoprefixerはこれと別途設定されている。
https://github.com/JeffreyWay/laravel-mix/blob/d0951a8f91feef2ff0d1dd4e8aba125c5aadf394/src/builder/webpack-rules.js#L160-L162
Autoprefixerはデフォルトでtrueになっている。
https://github.com/JeffreyWay/laravel-mix/blob/master/src/config.js#L108

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
3
Help us understand the problem. What are the problem?