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
|
// style-resources-loader
|
||||||
// https://github.com/yenshih/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({
|
loaders.push({
|
||||||
loader: 'style-resources-loader',
|
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
|
// https://github.com/postcss/postcss-loader
|
||||||
if (!isVueLoader) {
|
if (!isVueLoader) {
|
||||||
const _postcssConfig = postcssConfig.call(this)
|
const _postcssConfig = postcssConfig.call(this)
|
||||||
|
|
||||||
if (_postcssConfig) {
|
if (_postcssConfig) {
|
||||||
loaders.unshift({
|
loaders.unshift({
|
||||||
loader: 'postcss-loader',
|
loader: 'postcss-loader',
|
||||||
|
@ -170,6 +170,7 @@ Options.defaults = {
|
|||||||
app: 'app.[chunkhash].js',
|
app: 'app.[chunkhash].js',
|
||||||
chunk: '[name].[chunkhash].js'
|
chunk: '[name].[chunkhash].js'
|
||||||
},
|
},
|
||||||
|
styleResources: {},
|
||||||
vendor: [],
|
vendor: [],
|
||||||
plugins: [],
|
plugins: [],
|
||||||
babel: {},
|
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
|
generateStatsFile: true
|
||||||
},
|
},
|
||||||
styleResources: {
|
styleResources: {
|
||||||
patterns: [
|
scss: '~/assets/pre-process.scss'
|
||||||
'~/assets/pre-process.scss'
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
babel: {
|
babel: {
|
||||||
presets({ isServer }) {
|
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')
|
const loader = loaders.find(l => l.loader === 'style-resources-loader')
|
||||||
t.is(typeof loader, 'object')
|
t.is(typeof loader, 'object')
|
||||||
t.deepEqual(loader.options, {
|
t.deepEqual(loader.options, {
|
||||||
sourceMap: false,
|
patterns: ['~/assets/pre-process.scss']
|
||||||
patterns: [
|
|
||||||
'~/assets/pre-process.scss'
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user