mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 09:02:03 +00:00
fix(webpack): typecheck postcss plugins and add missing postcss-import
(resolves #544)
This commit is contained in:
parent
e2d216e4ee
commit
57f435a59f
@ -32,6 +32,7 @@
|
||||
"mini-css-extract-plugin": "^2.3.0",
|
||||
"pify": "^5.0.0",
|
||||
"postcss": "^8.3.6",
|
||||
"postcss-import": "^14.0.2",
|
||||
"postcss-import-resolver": "^2.0.0",
|
||||
"postcss-loader": "^6.1.1",
|
||||
"postcss-url": "^10.1.3",
|
||||
|
@ -3,7 +3,7 @@ import path from 'upath'
|
||||
import consola from 'consola'
|
||||
import { defaults, merge, cloneDeep } from 'lodash'
|
||||
import createResolver from 'postcss-import-resolver'
|
||||
import { Nuxt, tryRequireModule } from '@nuxt/kit'
|
||||
import { Nuxt, requireModule } from '@nuxt/kit'
|
||||
|
||||
const isPureObject = obj => obj !== null && !Array.isArray(obj) && typeof obj === 'object'
|
||||
|
||||
@ -138,20 +138,14 @@ export class PostcssConfig {
|
||||
}
|
||||
|
||||
loadPlugins (config) {
|
||||
const { plugins } = config
|
||||
if (isPureObject(plugins)) {
|
||||
// Map postcss plugins into instances on object mode once
|
||||
config.plugins = this.sortPlugins(config)
|
||||
.map((p) => {
|
||||
const plugin = tryRequireModule(p)
|
||||
const opts = plugins[p]
|
||||
if (opts === false) {
|
||||
return false // Disabled
|
||||
}
|
||||
return plugin(opts)
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
if (!isPureObject(config.plugins)) { return }
|
||||
// Map postcss plugins into instances on object mode once
|
||||
config.plugins = this.sortPlugins(config).map((pluginName) => {
|
||||
const pluginFn = requireModule(pluginName, { paths: [__dirname] })
|
||||
const pluginOptions = config.plugins[pluginName]
|
||||
if (!pluginOptions || typeof pluginFn !== 'function') { return null }
|
||||
return pluginFn(pluginOptions)
|
||||
}).filter(Boolean)
|
||||
}
|
||||
|
||||
config () {
|
||||
|
Loading…
Reference in New Issue
Block a user