mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
minor: Improve styleResources to handle multiple pre-provcessors
This commit is contained in:
parent
38d38d8d39
commit
eceb92502b
@ -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',
|
||||
|
@ -170,6 +170,7 @@ Options.defaults = {
|
||||
app: 'app.[chunkhash].js',
|
||||
chunk: '[name].[chunkhash].js'
|
||||
},
|
||||
styleResources: {},
|
||||
vendor: [],
|
||||
plugins: [],
|
||||
babel: {},
|
||||
|
4
test/fixtures/with-config/nuxt.config.js
vendored
4
test/fixtures/with-config/nuxt.config.js
vendored
@ -50,9 +50,7 @@ module.exports = {
|
||||
generateStatsFile: true
|
||||
},
|
||||
styleResources: {
|
||||
patterns: [
|
||||
'~/assets/pre-process.scss'
|
||||
]
|
||||
scss: '~/assets/pre-process.scss'
|
||||
},
|
||||
babel: {
|
||||
presets({ isServer }) {
|
||||
|
@ -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']
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user