minor: Improve styleResources to handle multiple pre-provcessors

This commit is contained in:
Sébastien Chopin 2018-01-08 10:37:10 +01:00
parent 38d38d8d39
commit eceb92502b
4 changed files with 9 additions and 9 deletions

View File

@ -20,10 +20,13 @@ module.exports = function styleLoader(ext, loaders = [], isVueLoader = false) {
// style-resources-loader
// https://github.com/yenshih/style-resources-loader
if (this.options.build.styleResources) {
if (this.options.build.styleResources[ext]) {
const patterns = Array.isArray(this.options.build.styleResources[ext]) ? this.options.build.styleResources[ext] : [ this.options.build.styleResources[ext] ]
const options = Object.assign({}, (this.options.build.styleResources.options || {}), { patterns })
loaders.push({
loader: 'style-resources-loader',
options: Object.assign({ sourceMap }, this.options.build.styleResources)
options
})
}
@ -32,6 +35,7 @@ module.exports = function styleLoader(ext, loaders = [], isVueLoader = false) {
// https://github.com/postcss/postcss-loader
if (!isVueLoader) {
const _postcssConfig = postcssConfig.call(this)
if (_postcssConfig) {
loaders.unshift({
loader: 'postcss-loader',

View File

@ -170,6 +170,7 @@ Options.defaults = {
app: 'app.[chunkhash].js',
chunk: '[name].[chunkhash].js'
},
styleResources: {},
vendor: [],
plugins: [],
babel: {},

View File

@ -50,9 +50,7 @@ module.exports = {
generateStatsFile: true
},
styleResources: {
patterns: [
'~/assets/pre-process.scss'
]
scss: '~/assets/pre-process.scss'
},
babel: {
presets({ isServer }) {

View File

@ -187,10 +187,7 @@ test('Check build.styleResources for style-resources-loader', async t => {
const loader = loaders.find(l => l.loader === 'style-resources-loader')
t.is(typeof loader, 'object')
t.deepEqual(loader.options, {
sourceMap: false,
patterns: [
'~/assets/pre-process.scss'
]
patterns: ['~/assets/pre-process.scss']
})
})