mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +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
|
||||
}
|
||||
|
||||
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.')
|
||||
options.build.postcss.postcssOptions.plugins = options.build.postcss.plugins
|
||||
delete options.build.postcss.plugins
|
||||
}
|
||||
|
||||
if (options.buildModules && options.buildModules.includes('@nuxt/postcss8')) {
|
||||
|
@ -195,12 +195,15 @@ export default class PostcssConfig {
|
||||
// Apply default plugins
|
||||
if (isPureObject(postcssOptions)) {
|
||||
const postcssLoaderOptions = this.postcssLoaderOptions
|
||||
if (postcssLoaderOptions.plugins && !postcssOptions.plugins) {
|
||||
postcssOptions.plugins = postcssLoaderOptions.plugins
|
||||
if (postcssLoaderOptions.plugins) {
|
||||
if (!postcssOptions.plugins || isPureObject(postcssOptions.plugins)) {
|
||||
postcssOptions.plugins = { ...postcssLoaderOptions.plugins || {}, ...postcssOptions.plugins || {} }
|
||||
}
|
||||
delete postcssLoaderOptions.plugins
|
||||
}
|
||||
if (postcssLoaderOptions.order && !postcssOptions.order) {
|
||||
postcssOptions.order = postcssLoaderOptions.order
|
||||
if ('order' in postcssLoaderOptions) {
|
||||
// Prioritise correct config value
|
||||
postcssOptions.order = postcssOptions.order || 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
|
||||
}
|
||||
},
|
||||
// deliberately invalid config to test normalization
|
||||
plugins: {
|
||||
cssnano: {}
|
||||
},
|
||||
postcssOptions: {
|
||||
plugins: {
|
||||
cssnano: {},
|
||||
[path.resolve(__dirname, 'plugins', 'tailwind.js')]: {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user