mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
fix(config): let webpack merge postcss plugins (#18839)
This commit is contained in:
parent
24432058e9
commit
6896e10599
@ -440,10 +440,8 @@ export function getNuxtConfig (_options) {
|
|||||||
delete options.build.crossorigin
|
delete options.build.crossorigin
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.build.postcss.plugins) {
|
if (options.build.postcss?.plugins) {
|
||||||
consola.warn('`postcss.plugins` option has been moved to `postcss.postcssOptions.plugins` for aligning `postcss-loader` format.')
|
consola.warn('`postcss.plugins` option has been moved to `postcss.postcssOptions.plugins` for aligning `postcss-loader` format.')
|
||||||
options.build.postcss.postcssOptions.plugins = options.build.postcss.plugins
|
|
||||||
delete options.build.postcss.plugins
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.buildModules && options.buildModules.includes('@nuxt/postcss8')) {
|
if (options.buildModules && options.buildModules.includes('@nuxt/postcss8')) {
|
||||||
|
@ -195,12 +195,15 @@ export default class PostcssConfig {
|
|||||||
// Apply default plugins
|
// Apply default plugins
|
||||||
if (isPureObject(postcssOptions)) {
|
if (isPureObject(postcssOptions)) {
|
||||||
const postcssLoaderOptions = this.postcssLoaderOptions
|
const postcssLoaderOptions = this.postcssLoaderOptions
|
||||||
if (postcssLoaderOptions.plugins && !postcssOptions.plugins) {
|
if (postcssLoaderOptions.plugins) {
|
||||||
postcssOptions.plugins = postcssLoaderOptions.plugins
|
if (!postcssOptions.plugins || isPureObject(postcssOptions.plugins)) {
|
||||||
|
postcssOptions.plugins = { ...postcssLoaderOptions.plugins || {}, ...postcssOptions.plugins || {} }
|
||||||
|
}
|
||||||
delete postcssLoaderOptions.plugins
|
delete postcssLoaderOptions.plugins
|
||||||
}
|
}
|
||||||
if (postcssLoaderOptions.order && !postcssOptions.order) {
|
if ('order' in postcssLoaderOptions) {
|
||||||
postcssOptions.order = postcssLoaderOptions.order
|
// Prioritise correct config value
|
||||||
|
postcssOptions.order = postcssOptions.order || postcssLoaderOptions.order
|
||||||
delete postcssLoaderOptions.order
|
delete postcssLoaderOptions.order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
test/fixtures/basic/nuxt.config.js
vendored
5
test/fixtures/basic/nuxt.config.js
vendored
@ -95,9 +95,12 @@ export default {
|
|||||||
'custom-selectors': true
|
'custom-selectors': true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// deliberately invalid config to test normalization
|
||||||
|
plugins: {
|
||||||
|
cssnano: {}
|
||||||
|
},
|
||||||
postcssOptions: {
|
postcssOptions: {
|
||||||
plugins: {
|
plugins: {
|
||||||
cssnano: {},
|
|
||||||
[path.resolve(__dirname, 'plugins', 'tailwind.js')]: {}
|
[path.resolve(__dirname, 'plugins', 'tailwind.js')]: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user