2016-10-26 14:46:32 +00:00
|
|
|
var path = require('path')
|
|
|
|
var config = require('../config')
|
2019-04-07 17:33:11 +00:00
|
|
|
var sass = require('sass')
|
|
|
|
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2016-10-26 14:46:32 +00:00
|
|
|
|
|
|
|
exports.assetsPath = function (_path) {
|
|
|
|
var assetsSubDirectory = process.env.NODE_ENV === 'production'
|
2019-04-07 17:33:11 +00:00
|
|
|
? config.build.assetsSubDirectory
|
|
|
|
: config.dev.assetsSubDirectory
|
2016-10-26 14:46:32 +00:00
|
|
|
return path.posix.join(assetsSubDirectory, _path)
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.cssLoaders = function (options) {
|
|
|
|
options = options || {}
|
|
|
|
|
2019-04-07 17:33:11 +00:00
|
|
|
function generateLoaders (loaders) {
|
2016-10-26 14:46:32 +00:00
|
|
|
// Extract CSS when that option is specified
|
|
|
|
// (which is the case during production build)
|
|
|
|
if (options.extract) {
|
2019-04-07 17:33:11 +00:00
|
|
|
return [MiniCssExtractPlugin.loader].concat(loaders)
|
2016-10-26 14:46:32 +00:00
|
|
|
} else {
|
2019-04-07 17:33:11 +00:00
|
|
|
return ['vue-style-loader'].concat(loaders)
|
2016-10-26 14:46:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
|
2019-04-07 17:33:11 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
test: /\.(post)?css$/,
|
2019-08-13 22:18:07 +00:00
|
|
|
use: generateLoaders(['css-loader', 'postcss-loader']),
|
2019-04-07 17:33:11 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
2019-08-13 22:18:07 +00:00
|
|
|
use: generateLoaders(['css-loader', 'postcss-loader', 'less-loader']),
|
2019-04-07 17:33:11 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.sass$/,
|
|
|
|
use: generateLoaders([
|
|
|
|
'css-loader',
|
2019-08-13 22:18:07 +00:00
|
|
|
'postcss-loader',
|
2019-04-07 17:33:11 +00:00
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
indentedSyntax: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
])
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
2019-08-13 22:18:07 +00:00
|
|
|
use: generateLoaders(['css-loader', 'postcss-loader', 'sass-loader'])
|
2019-04-07 17:33:11 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.styl(us)?$/,
|
2019-08-13 22:18:07 +00:00
|
|
|
use: generateLoaders(['css-loader', 'postcss-loader', 'stylus-loader']),
|
2019-04-07 17:33:11 +00:00
|
|
|
},
|
|
|
|
]
|
2016-10-26 14:46:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Generate loaders for standalone style files (outside of .vue)
|
|
|
|
exports.styleLoaders = function (options) {
|
2019-05-21 18:22:00 +00:00
|
|
|
return exports.cssLoaders(options)
|
2016-10-26 14:46:32 +00:00
|
|
|
}
|