2016-11-10 02:38:11 +00:00
|
|
|
'use strict'
|
|
|
|
|
2016-12-13 16:39:59 +00:00
|
|
|
const { defaults } = require('lodash')
|
|
|
|
|
2016-11-09 22:59:41 +00:00
|
|
|
module.exports = function () {
|
2016-12-13 16:39:59 +00:00
|
|
|
let babelOptions = JSON.stringify(defaults(this.options.build.babel, {
|
2016-12-27 15:58:07 +00:00
|
|
|
plugins: [
|
|
|
|
'transform-async-to-generator',
|
|
|
|
'transform-runtime'
|
|
|
|
],
|
2016-12-13 16:37:53 +00:00
|
|
|
presets: [
|
|
|
|
['es2015', { modules: false }],
|
|
|
|
'stage-2'
|
|
|
|
]
|
2016-12-13 16:39:59 +00:00
|
|
|
}))
|
2016-11-09 22:59:41 +00:00
|
|
|
let 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,
|
2016-11-09 22:59:41 +00:00
|
|
|
'less': 'vue-style-loader!css-loader!less-loader',
|
|
|
|
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax',
|
|
|
|
'scss': 'vue-style-loader!css-loader!sass-loader',
|
|
|
|
'stylus': 'vue-style-loader!css-loader!stylus-loader',
|
|
|
|
'styl': 'vue-style-loader!css-loader!stylus-loader'
|
2016-12-20 10:58:32 +00:00
|
|
|
},
|
|
|
|
preserveWhitespace: false
|
2016-11-07 01:34:58 +00:00
|
|
|
}
|
2016-11-09 22:59:41 +00:00
|
|
|
|
|
|
|
if (!this.dev) {
|
|
|
|
// Use ExtractTextPlugin to extract CSS into a single file
|
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
|
|
|
config.loaders.css = ExtractTextPlugin.extract({ loader: 'css-loader' })
|
|
|
|
config.loaders.scss = ExtractTextPlugin.extract({ loader: 'css-loader!sass-loader', fallbackLoader: 'vue-style-loader' })
|
|
|
|
config.loaders.sass = ExtractTextPlugin.extract({ loader: 'css-loader!sass-loader?indentedSyntax', fallbackLoader: 'vue-style-loader' })
|
|
|
|
config.loaders.stylus = ExtractTextPlugin.extract({ loader: 'css-loader!stylus-loader', fallbackLoader: 'vue-style-loader' })
|
|
|
|
config.loaders.less = ExtractTextPlugin.extract({ loader: 'css-loader!less-loader', fallbackLoader: 'vue-style-loader' })
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return the config
|
|
|
|
return config
|
2016-11-07 01:34:58 +00:00
|
|
|
}
|