Skip to content

IMPORTANT NOTES #14

Description

@MrRaindrop

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')()]
      }
    }
  ]
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions