import { defaults } from 'lodash'
import { extractStyles, styleLoader } from './helpers'

export default function ({ isClient }) {
  let babelOptions = JSON.stringify(defaults(this.options.build.babel, {
    presets: [require.resolve('babel-preset-vue-app')],
    babelrc: false,
    cacheDirectory: !!this.options.dev
  }))

  // https://github.com/vuejs/vue-loader/blob/master/docs/en/configurations
  const config = {
    postcss: this.options.build.postcss,
    loaders: {
      'js': 'babel-loader?' + babelOptions,
      'css': styleLoader.call(this, 'css'),
      'less': styleLoader.call(this, 'less', 'less-loader'),
      'sass': styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax&sourceMap'),
      'scss': styleLoader.call(this, 'sass', 'sass-loader?sourceMap'),
      'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'),
      'styl': styleLoader.call(this, 'stylus', 'stylus-loader')
    },
    preserveWhitespace: false,
    extractCSS: extractStyles.call(this)
  }

  // Return the config
  return config
}

import { defaults } from 'lodash'
import { extractStyles, styleLoader } from './helpers'

export default function ({ isClient }) {
  let babelOptions = JSON.stringify(defaults(this.options.build.babel, {
    presets: [require.resolve('babel-preset-vue-app')],
    babelrc: false,
    cacheDirectory: !!this.options.dev
  }))

  // https://github.com/vuejs/vue-loader/blob/master/docs/en/configurations
  const config = {
    postcss: this.options.build.postcss,
    loaders: {
      'js': 'babel-loader?' + babelOptions,
      'css': styleLoader.call(this, 'css'),
      'less': styleLoader.call(this, 'less', 'less-loader'),
      'sass': styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax&sourceMap'),
      'scss': styleLoader.call(this, 'sass', 'sass-loader?sourceMap'),
      'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'),
      'styl': styleLoader.call(this, 'stylus', 'stylus-loader')
    },
    template: {
      // for pug, see https://github.com/vuejs/vue-loader/issues/55
      doctype: "html"
    },
    preserveWhitespace: false,
    extractCSS: extractStyles.call(this)
  }

  // Return the config
  return config
}

Add better support for pug
Add better support for pug

When using `lang="pug"`, passing Boolean `true` as prop and using directives will case errors.

See: 
https://github.com/vuejs/vue-loader/issues/693
https://github.com/vuejs/vue-loader/issues/55

For example:

```html
<template lang="pug">
foo(
  bar
  v-baz-directive
)
</template>
```

This will be rendered as
`<foo bar="bar" v-baz-directive="v-baz-directive">`
and cause errors such as `bar expected Boolean but got String` and `v`/`baz`/`directive` not defined.