在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 使用vue-cli新建webpack項目時如何使用postcss,及postcs

使用vue-cli新建webpack項目時如何使用postcss,及postcss相關插件

使用vue-cli腳手架新建了一個以webpack模版的項目,想在單組件的項目中使用postcss書寫css,在vue-loader.conf.js中引用了postcss-cssnext與precss

var utils = require('./utils')
var config = require('../config')
var isProduction = process.env.NODE_ENV === 'production'

module.exports = {
  loaders: utils.cssLoaders({
    sourceMap: isProduction
      ? config.build.productionSourceMap
      : config.dev.cssSourceMap,
    extract: isProduction
  }),
  transformToRequire: {
    video: 'src',
    source: 'src',
    img: 'src',
    image: 'xlink:href'
  },
  postcss: [require('postcss-cssnext')(), require('precss')()]
}

測試使用postcss-cssnext時是有效的,但是用precss嵌套書寫的時候就報錯

<template lang="pug">
  #app
    router-view
</template>

<script>
  export default {
    name: 'app'
  }
</script>

<style lang="postcss">
  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: gray(85);
    margin-top: 60px;
    img {
      color: gray(60);
    }
  }
</style>

錯誤信息:

Module build failed: TypeError: after.after is not a function
    at F:\www\yq\node_modules\_postcss-nested@2.1.0@postcss-nested\index.js:71:19
    at Rule.each (F:\www\yq\node_modules\_postcss@5.2.17@postcss\lib\container.js:114:22)
    at processRule (F:\www\yq\node_modules\_postcss-nested@2.1.0@postcss-nested\index.js:66:10)
    at F:\www\yq\node_modules\_postcss-nested@2.1.0@postcss-nested\index.js:101:17
    at Root.each (F:\www\yq\node_modules\_postcss@5.2.17@postcss\lib\container.js:114:22)
    at process (F:\www\yq\node_modules\_postcss-nested@2.1.0@postcss-nested\index.js:99:14)
    at LazyResult.run (F:\www\yq\node_modules\_postcss@5.2.17@postcss\lib\lazy-result.js:274:20)
    at LazyResult.asyncTick (F:\www\yq\node_modules\_postcss@5.2.17@postcss\lib\lazy-result.js:189:32)
回答
編輯回答
浪蕩不羈

webpack 1.0 的less 寫法!!! 和你的那個postcss一樣的東西

{
    test : /\.(less|css)$/,
    loader: ExtractTextPlugin.extract('style', 'css!less')
},
2017年6月4日 22:56
編輯回答
浪蕩不羈

兩個插件的順序換一下

2017年2月24日 00:37