2017-01-11 19:14:59 +00:00
|
|
|
import { defaults } from 'lodash'
|
2017-04-30 11:58:25 +00:00
|
|
|
import { extractStyles, styleLoader } from './helpers'
|
2016-12-13 16:39:59 +00:00
|
|
|
|
2017-01-11 19:14:59 +00:00
|
|
|
export default function ({ isClient }) {
|
2016-12-13 16:39:59 +00:00
|
|
|
let babelOptions = JSON.stringify(defaults(this.options.build.babel, {
|
2017-07-31 21:27:22 +00:00
|
|
|
presets: [require.resolve('babel-preset-vue-app')],
|
2017-04-17 13:27:32 +00:00
|
|
|
babelrc: false,
|
2017-06-11 14:17:36 +00:00
|
|
|
cacheDirectory: !!this.options.dev
|
2016-12-13 16:39:59 +00:00
|
|
|
}))
|
2017-04-30 11:58:25 +00:00
|
|
|
|
|
|
|
// https://github.com/vuejs/vue-loader/blob/master/docs/en/configurations
|
2017-06-15 22:19:53 +00:00
|
|
|
const config = {
|
2016-11-22 23:47:31 +00:00
|
|
|
postcss: this.options.build.postcss,
|
2016-11-09 22:59:41 +00:00
|
|
|
loaders: {
|
2016-12-13 16:37:53 +00:00
|
|
|
'js': 'babel-loader?' + babelOptions,
|
2017-04-30 11:58:25 +00:00
|
|
|
'css': styleLoader.call(this, 'css'),
|
|
|
|
'less': styleLoader.call(this, 'less', 'less-loader'),
|
2017-07-27 08:22:25 +00:00
|
|
|
'sass': styleLoader.call(this, 'sass', 'sass-loader?indentedSyntax&sourceMap'),
|
2017-05-09 11:24:55 +00:00
|
|
|
'scss': styleLoader.call(this, 'sass', 'sass-loader?sourceMap'),
|
2017-04-30 11:58:25 +00:00
|
|
|
'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'),
|
|
|
|
'styl': styleLoader.call(this, 'stylus', 'stylus-loader')
|
2016-12-20 10:58:32 +00:00
|
|
|
},
|
2017-08-13 09:00:05 +00:00
|
|
|
template: {
|
|
|
|
// for pug, see https://github.com/vuejs/vue-loader/issues/55
|
2017-08-13 09:03:34 +00:00
|
|
|
doctype: 'html'
|
2017-08-13 09:00:05 +00:00
|
|
|
},
|
2017-04-30 11:58:25 +00:00
|
|
|
preserveWhitespace: false,
|
2017-05-05 15:53:21 +00:00
|
|
|
extractCSS: extractStyles.call(this)
|
2016-11-07 01:34:58 +00:00
|
|
|
}
|
2017-06-15 22:19:53 +00:00
|
|
|
|
2016-11-09 22:59:41 +00:00
|
|
|
// Return the config
|
|
|
|
return config
|
2016-11-07 01:34:58 +00:00
|
|
|
}
|