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