Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMPORTANT NOTES #14

Open
MrRaindrop opened this issue Mar 27, 2017 · 6 comments
Open

IMPORTANT NOTES #14

MrRaindrop opened this issue Mar 27, 2017 · 6 comments

Comments

@MrRaindrop
Copy link
Owner

MrRaindrop commented Mar 27, 2017

vue-loader config

you should use $processStyle in vue-loader's postTransformNode config.

Otherwise, the inline style or binding style will not be auto-prefixed.

See a example:

/**
 * //////////////////////////////
 * webpack 1.x:
 * //////////////////////////////
 */
module: {
  loaders: [
    {
      test: /\.js$/,
      loaders: ['babel-loader'],
      exclude: /node_modules/
    }, {
      test: /\.vue(\?[^?]+)?$/,
      loaders: ['vue-loader']
    }
  ]
},
vue: {
  /**
   * important! should use postTransformNode to add $processStyle for
   * inline style prefixing.
   */
  compilerModules: [
    {
      postTransformNode: el => {
        el.staticStyle = `$processStyle(${el.staticStyle})`
        el.styleBinding = `$processStyle(${el.styleBinding})`
      }
    }
  ],
  postcss: [require('autoprefixer')()]
}

/**
 * //////////////////////////////
 * webpack 2.x:
 * //////////////////////////////
 */
module: {
  rules: [
    {
      test: /\.jsx?$/,
      exclude: /node_modules/,
      loader: 'babel-loader',
      options: {
        presets: ['es2015']
      }
    }, {
      test: /\.vue(\?[^?]+)?$/,
      loader: 'vue-loader',
      options: {
        /**
         * important! should use postTransformNode to add $processStyle for
         * inline style prefixing.
         */
        compilerModules: [
          {
            postTransformNode: el => {
              el.staticStyle = `$processStyle(${el.staticStyle})`
              el.styleBinding = `$processStyle(${el.styleBinding})`
            }
          }
        ],
        postcss: [require('autoprefixer')()]
      }
    }
  ]
}
@grasslandKiss
Copy link

@MrRaindrop 基于webpack2.0,vue-loader添加如上options,并未解决题中所示报错,另外,而此报错导致的问题是在web端无法识别html入口页面引入的style不起启用,导致整体页面呈现有差

@MrRaindrop
Copy link
Owner Author

@grasslandKiss 这个报错没有中断代码执行,只是一个 warn. 另外需要把你的 vue-loader 版本升级到最新版本: 11.3.x 因为这个是 vue-loader 最新版本的特性. 如果还是不行,提供我一个出错的 demo, 我看一下

@grasslandKiss
Copy link

@MrRaindrop 一旦升级,会报错vue,vue-template-compiler与vue-loader版本不匹配的错误(前提是已安装对应的[email protected],[email protected])

@MrRaindrop
Copy link
Owner Author

升级 vue 到 2.2.6 版本就和 vue-template-compiler 匹配了. 这个是 vuejs 自己的提示,和 weex-vue-render 没有太大关系. 你只要确保把 vue-loader 升级到最新版本就可以了.

@MrRaindrop
Copy link
Owner Author

@grasslandKiss 0.11.2 已降级为 warning. 页面里没有用到 inline style or style binding 的时候,$processStyle 仍然会出此警告(因为没有被调用),忽略即可.

@grasslandKiss
Copy link

@MrRaindrop 已忽略,你人好好喔!感谢你!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants