1
0
Fork 0
forked from srxl/akkoma-fe
akkoma-fe/build/utils.js

64 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-10-26 14:46:32 +00:00
var path = require('path')
var config = require('../config')
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'
? 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 || {}
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) {
return [MiniCssExtractPlugin.loader].concat(loaders)
2016-10-26 14:46:32 +00:00
} else {
return ['vue-style-loader'].concat(loaders)
2016-10-26 14:46:32 +00:00
}
}
// http://vuejs.github.io/vue-loader/configurations/extract-css.html
return [
{
test: /\.(post)?css$/,
use: generateLoaders(['css-loader', 'postcss-loader']),
},
{
test: /\.less$/,
use: generateLoaders(['css-loader', 'postcss-loader', 'less-loader']),
},
{
test: /\.sass$/,
use: generateLoaders([
'css-loader',
'postcss-loader',
{
loader: 'sass-loader',
options: {
indentedSyntax: true
}
}
])
},
{
test: /\.scss$/,
use: generateLoaders(['css-loader', 'postcss-loader', 'sass-loader'])
},
{
test: /\.styl(us)?$/,
use: generateLoaders(['css-loader', 'postcss-loader', 'stylus-loader']),
},
]
2016-10-26 14:46:32 +00:00
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
return exports.cssLoaders(options)
2016-10-26 14:46:32 +00:00
}