3

I am building a nuxt application and using scss for styling.

I have installed node-sass and sass-loader & now am able to load external scss files. This global file is being processed by autoprefixer (for eg.: If I do display: flex, it automatically adds display: -webkit-box; display: -ms-flexbox;),

I have added these lines from doc to my nuxt.config.js file and have installed 4 pakcages as mentioned below (postcss-url, postcss-nested etc..)

postcss: {
            plugins: {
                'postcss-url': false,
                'postcss-nested': {},
                'postcss-responsive-type': {},
                'postcss-hexrgba': {}
            },
            preset: {
                autoprefixer: {
                    grid: true,
                    flexbox: true
                }
            }
        },

I expect my inline stylle with lang="scss" should also work in a same way as the global scss file(for eg.: If I do display: flex, it automatically adds display: -webkit-box; display: -ms-flexbox;).

Ravi Wadhwani
  • 145
  • 3
  • 12

4 Answers4

5

You can add in package.json after devDependencies - "browserslist": "cover 99.5%"

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
1

maybe this will help you

preset: {
    autoprefixer: {
      flexbox: true,
      grid: true,
      overrideBrowserslist: ['last 3 versions', '> 1%', 'ie 8', 'ie 7'],
    },
  },
0

Autoprefixer should be enabled by default in Nuxt. If you want, you can adjust the settings. More info here: https://nuxtjs.org/api/configuration-build/#postcss

  • 1
    It does works as separate scss file, but I would like to know how inline scss style work? I mean how autoprefixer can work inline also in single-file component. – Ravi Wadhwani Dec 27 '19 at 16:42
0

Autoprefixer should be enabled by default in Nuxt I have used in my project and resolved for IE9 and above version

build: {
    postcss: [
      require('autoprefixer')({
        overrideBrowserslist: ['cover 99.5%', 'not IE < 9']
      })
    ],
}