首先install  autoprefixer

然后在根目录添加.postcssrc.js

内容为

module.exports = {
  "plugins": {
    // to edit target browsers: use "browserlist" field in package.json
    "autoprefixer": {
    }
  }
}
或者在package.json 添加

"browserslist": [
  "last 3 versions", "> 1%",  "Firefox ESR", "Opera 12.1"
]

外部scss添加 postcss 

首先 install  postcss-loader 

然后在utils文件的中添加 postcss-loader 相关部分 

exports.cssLoaders = function (options) {
  options = options || {}

  var cssLoader = {
    loader: 'css-loader',
    options: {
      minimize: false,
      sourceMap: false
    }
  }

  var postcssLoader = {
    loader: 'postcss-loader',
    options: {
      sourceMap: false
    }
  }

  // generate loader string to be used with extract text plugin
  function generateLoaders (loader, loaderOptions) {
    var loaders = [cssLoader]
    if (loader) {
      loaders.push(postcssLoader)
      loaders.push({
        loader: loader + '-loader',
        options: Object.assign({}, loaderOptions, {
          sourceMap: false
        })
      })
    }

    // Extract CSS when that option is specified
    // (which is the case during production build)
    if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        fallback: 'vue-style-loader'
      })
    } else {
      return ['vue-style-loader'].concat(loaders)
    }
  }

  // https://vue-loader.vuejs.org/en/configurations/extract-css.html
  return {
    css: generateLoaders(),
    postcss: generateLoaders(),
    less: generateLoaders('less'),
    sass: generateLoaders('sass', { indentedSyntax: true }),
    scss: generateLoaders('sass'),
    stylus: generateLoaders('stylus'),
    styl: generateLoaders('stylus')
  }
}

Logo

前往低代码交流专区

更多推荐