These are chat archives for QingWei-Li/cooking

9th
Sep 2016
isunkui
@isunkui
Sep 09 2016 02:11
帅锅,1.0版本的cooking,自定义postcss插件,config这个要怎么配置呢
> cooking build -p

[cooking] - Failed to read the config.
[cooking] - TypeError: (cooking.config.postcss || []).concat is not a function
    at module.exports (/Users/isunkui/.cooking/node_modules/cooking-autoprefixer/index.js:6:59)
    at importExtend (/usr/local/lib/node_modules/cooking-cli/util/load-extend.js:11:31)
    at Object.keys.reverse.forEach.key (/usr/local/lib/node_modules/cooking-cli/util/load-extend.js:47:5)
    at Array.forEach (native)
    at module.exports (/usr/local/lib/no
cinwell.li
@QingWei-Li
Sep 09 2016 02:13
cooking.set({
  postcss: [
    require('postcss-plugin'),
    require('autoprefixer') // 如果使用 vue-loader^8.0.0 需要手动关掉里面的 autoprefixer
    // xxx
  ]
})

// cooking.add('vue.autoprefixer', false)
cooking-autoprefixer 用不了?
isunkui
@isunkui
Sep 09 2016 02:26
还是有些问题,postcss配置的插件没有生效,config如下:
cooking.set({
  postcss: [
    require('postcss-salad')({
      browser: ['> 0.1%', 'iOS 7'],
      features: {
        rem: false,
        autoprefixer: ['> 0.1%', 'iOS 7']
        // 'rem': {rootValue: 75},
        // 'bem': false
      }
    }),
    require('postcss-center'),
    require('postcss-px2rem')({remUnit: 75})
  ],
  extends: ['vue', 'lint', 'saladcss']
});
cinwell.li
@QingWei-Li
Sep 09 2016 02:27
saladcss 去掉
配置了 postcss 就不用 saladcss 插件了
两者不共存
isunkui
@isunkui
Sep 09 2016 02:28
这个我试过了,但是会有下面的错误
Child cooking.conf.js:

    ERROR in /usr/local/lib/~/cooking-cli/~/css-loader?sourceMap!/Users/isunkui/.cooking/~/vue-loader/lib/style-rewriter.js!/Users/isunkui/.cooking/~/vue-loader/lib/selector.js?type=style&index=0!./src/app.vue
    Module build failed: Error: undefined:1:16: missing '{'
        at error (/Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/css/lib/parse/index.js:62:15)
        at declarations (/Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/css/lib/parse/index.js:247:25)
        at rule (/Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/css/lib/parse/index.js:560:21)
        at rules (/Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/css/lib/parse/index.js:117:70)
        at stylesheet (/Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/css/lib/parse/index.js:81:21)
        at Object.module.exports [as parse] (/Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/css/lib/parse/index.js:564:20)
        at Px2rem.generateRem (/Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/px2rem/lib/px2rem.js:70:20)
        at /Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/postcss-px2rem/lib/index.js:10:32
        at plugins.map.plugin (/usr/local/lib/node_modules/cooking-cli/node_modules/cooking/util/load-postcss.js:11:57)
        at Array.map (native)
        at Object.postcss (/usr/local/lib/node_modules/cooking-cli/node_modules/cooking/util/load-postcss.js:11:22)
        at Object.module.exports (/Users/isunkui/.cooking/node_modules/vue-loader/lib/style-rewriter.js:45:30)
     @ /Users/isunkui/.cooking/~/vue-style-loader!/usr/local/lib/~/cooking-cli/~/css-loader?sourceMap!/Users/isunkui/.cooking/~/vue-loader/lib/style-rewriter.js!/Users/isunkui/.cooking/~/vue-loader/lib/selector.js?type=style&index=0!./src/app.vue 4:14-347 13:2-17:4 14:20-353
     @ ./src/app.vue
     @ ./src/main.js
     @ multi app
cinwell.li
@QingWei-Li
Sep 09 2016 02:29
missing ‘{‘ 这个错是啥。。。
isunkui
@isunkui
Sep 09 2016 02:31
去掉postcss-px2rem确实是生效了,我用的插件出错了,我在看看
isunkui
@isunkui
Sep 09 2016 02:53
引入postcss-pxtorem也报错了,应该还是有些问题的,我还是改用之前的方式了,参考cooking-salad的方式引入了
cinwell.li
@QingWei-Li
Sep 09 2016 02:53
抱啥错。。
这里面并没有做啥处理啊 = =
isunkui
@isunkui
Sep 09 2016 02:54
Child cooking.conf.js:

    ERROR in /usr/local/lib/~/cooking-cli/~/css-loader?sourceMap!/Users/isunkui/.cooking/~/vue-loader/lib/style-rewriter.js!/Users/isunkui/.cooking/~/vue-loader/lib/selector.js?type=style&index=0!./src/app.vue
    Module build failed: TypeError: css.walkDecls is not a function
        at /Volumes/file/d/workspace/doufan/df-workflow/app/node_modules/postcss-pxtorem/index.js:34:13
        at plugins.map.plugin (/usr/local/lib/node_modules/cooking-cli/node_modules/cooking/util/load-postcss.js:11:57)
        at Array.map (native)
        at Object.postcss (/usr/local/lib/node_modules/cooking-cli/node_modules/cooking/util/load-postcss.js:11:22)
        at Object.module.exports (/Users/isunkui/.cooking/node_modules/vue-loader/lib/style-rewriter.js:45:30)
     @ /Users/isunkui/.cooking/~/vue-style-loader!/usr/local/lib/~/cooking-cli/~/css-loader?sourceMap!/Users/isunkui/.cooking/~/vue-loader/lib/style-rewriter.js!/Users/isunkui/.cooking/~/vue-loader/lib/selector.js?type=style&index=0!./src/app.vue 4:14-347 13:2-17:4 14:20-353
     @ ./src/app.vue
     @ ./src/main.js
     @ multi app
    Child html-webpack-plugin for "index.html":
跟sourceMap有关吗
我将他设为false也有问题
cinwell.li
@QingWei-Li
Sep 09 2016 02:55
那你设置 sourceMap: false 被
不清楚啥问题 也有可能是 postcss-salad
你把 salad 放在最后
先用 px2rem 处理
isunkui
@isunkui
Sep 09 2016 02:56
有试过,也有这个问题
两个插件,你说的这个方式都试过
我通过下面这种方式调用就没问题
var plugins = [
  require('postcss-salad')({
    browser: ['> 0.1%', 'iOS 7'],
    features: {
      rem: false,
      autoprefixer: ['> 0.1%', 'iOS 7'],
      // 'rem': {rootValue: 75},
      // 'bem': false
    }
  }),
  require('postcss-center'),
  require('postcss-px2rem')({remUnit: 75})
];

cooking.add('postcss', function () {
  return plugins;
});

cooking.add('vue.postcss', function () {
  return plugins;
});
cinwell.li
@QingWei-Li
Sep 09 2016 02:58
这样就不报错么
isunkui
@isunkui
Sep 09 2016 02:58
是的,这样使用就达到了我预期的效果
cinwell.li
@QingWei-Li
Sep 09 2016 02:59
好 我研究下
wltony
@wltony
Sep 09 2016 04:21
现在cooking-cli 支持vue 2.0么
cinwell.li
@QingWei-Li
Sep 09 2016 04:55
支持啊
只是脚手架我还没更新
明天弄
wltony
@wltony
Sep 09 2016 04:59
真勤快,现在用脚手架,需要手动改些啥,不过多话我就先手动改改。
cinwell.li
@QingWei-Li
Sep 09 2016 05:01
不需要改啥吧 只是到时候把 vue 和 vue2 两个脚手架合并成一个 然后把新版本的一些特性 postcss 啥的加上去,然后提供一个是否安装本地版本的 cooking 的选项
大致这些
wltony
@wltony
Sep 09 2016 05:49
Ok