Webpack: Autoprefixer does not prefix imported css files

Created on 23 Dec 2016  路  6Comments  路  Source: vuejs-templates/webpack

I'm having a problem with imported css files, which will not be prefixed.

I know I have to solve this issue somehow by the loader, but I can't really figure out how.

So here is an example

@import '~vue-material/dist/vue-material.css';

.md-button
  &.md-icon-button
    .md-icon
      transform: translate(-50%, -50%)

the self written rule in the sass file will be prefixed as it should, but the imported vue-material.css will not be prefixed.

Can anyone explain to me, how i have to change the loaders, so they will prefix everything?

Most helpful comment

Okay so I actually just got it to work a few minutes after posting this issue.

We included the postcss-import module into the loader and it works fine

in webpack.base.conf.js

vue: {
    loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
    postcss: [
      require('postcss-import')(),
      require('autoprefixer')({
        browsers: ['> 1%']
      })
    ]
  }

the only question that remains is if there is any other way to do this, so that i don't need another module. Help would be great!

All 6 comments

Okay so I actually just got it to work a few minutes after posting this issue.

We included the postcss-import module into the loader and it works fine

in webpack.base.conf.js

vue: {
    loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
    postcss: [
      require('postcss-import')(),
      require('autoprefixer')({
        browsers: ['> 1%']
      })
    ]
  }

the only question that remains is if there is any other way to do this, so that i don't need another module. Help would be great!

If you require css in js file, it`s no use

import 'main.css'

Close (in-activity)

@alex-schmidigital doesn't work for me, i use [email protected] build the full webpack vue proj, add webpack config in vue-loader.conf.js like this:

  module.exports = {
  loaders: utils.cssLoaders({
    sourceMap: isProduction
      ? config.build.productionSourceMap
      : config.dev.cssSourceMap,
    extract: isProduction
  }),
  postcss: [
    require('postcss-import')(),
    require('autoprefixer')({
      browsers: ['last 5 versions', 'Android >= 2.0']
    })
  ]
}

i learn to use [email protected], but not practise, anyone can help? tks

@RunningV Autoprefixer works ,but 'hot-reload' doesn't work

Back link to stackoverflow. I can't get this working with my build.
https://stackoverflow.com/questions/45208186/vue-webpack-2-autoprefixer-for-ie9

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulgeisler picture paulgeisler  路  3Comments

nicolas-t picture nicolas-t  路  4Comments

SSmale picture SSmale  路  3Comments

connor11528 picture connor11528  路  3Comments

Joshfindit picture Joshfindit  路  3Comments