2018-03-16 16:12:06 +00:00
|
|
|
import postcssConfig from './postcss'
|
2018-03-21 11:34:16 +00:00
|
|
|
import styleLoaderWrapper from './style-loader'
|
2017-12-28 16:05:34 +00:00
|
|
|
|
2018-03-16 16:12:06 +00:00
|
|
|
export default function vueLoader({ isServer }) {
|
2017-08-14 14:03:07 +00:00
|
|
|
// https://vue-loader.vuejs.org/en
|
2018-03-21 11:34:16 +00:00
|
|
|
const styleLoader = styleLoaderWrapper({
|
|
|
|
isServer,
|
|
|
|
isVueLoader: true
|
|
|
|
})
|
2017-06-15 22:19:53 +00:00
|
|
|
const config = {
|
2017-12-28 16:05:34 +00:00
|
|
|
postcss: postcssConfig.call(this),
|
2017-08-14 14:03:07 +00:00
|
|
|
cssSourceMap: this.options.build.cssSourceMap,
|
|
|
|
preserveWhitespace: false,
|
2016-11-09 22:59:41 +00:00
|
|
|
loaders: {
|
2018-01-13 05:22:11 +00:00
|
|
|
js: {
|
2017-08-14 14:03:07 +00:00
|
|
|
loader: 'babel-loader',
|
2017-12-08 14:18:37 +00:00
|
|
|
options: this.getBabelOptions({ isServer })
|
2017-08-14 14:03:07 +00:00
|
|
|
},
|
|
|
|
// Note: do not nest the `postcss` option under `loaders`
|
2018-03-21 11:34:16 +00:00
|
|
|
css: styleLoader.call(this, 'css', []),
|
|
|
|
less: styleLoader.call(this, 'less', 'less-loader'),
|
|
|
|
scss: styleLoader.call(this, 'scss', 'sass-loader'),
|
2018-01-13 05:22:11 +00:00
|
|
|
sass: styleLoader.call(
|
|
|
|
this,
|
|
|
|
'sass',
|
2018-03-21 11:34:16 +00:00
|
|
|
{ loader: 'sass-loader', options: { indentedSyntax: true } }
|
2018-01-13 05:22:11 +00:00
|
|
|
),
|
2018-03-21 11:34:16 +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: {
|
2017-08-14 14:03:07 +00:00
|
|
|
doctype: 'html' // For pug, see https://github.com/vuejs/vue-loader/issues/55
|
2017-11-03 02:36:01 +00:00
|
|
|
},
|
|
|
|
transformToRequire: {
|
|
|
|
video: 'src',
|
2017-11-14 03:14:37 +00:00
|
|
|
source: 'src',
|
|
|
|
object: 'src',
|
|
|
|
embed: 'src'
|
2017-08-14 14:03:07 +00:00
|
|
|
}
|
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
|
|
|
}
|