2021-11-21 16:14:46 +00:00
|
|
|
import { requireModule } from '@nuxt/kit'
|
|
|
|
import type { Nuxt } from '@nuxt/schema'
|
2022-02-25 19:11:01 +00:00
|
|
|
import type { ViteOptions } from './vite'
|
2021-10-13 20:08:26 +00:00
|
|
|
import { distDir } from './dirs'
|
|
|
|
|
|
|
|
export function resolveCSSOptions (nuxt: Nuxt): ViteOptions['css'] {
|
|
|
|
const css: ViteOptions['css'] = {
|
|
|
|
postcss: {
|
|
|
|
plugins: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-25 19:11:01 +00:00
|
|
|
const plugins = nuxt.options.postcss.plugins
|
2021-10-13 20:08:26 +00:00
|
|
|
|
|
|
|
for (const name in plugins) {
|
|
|
|
const opts = plugins[name]
|
|
|
|
if (!opts) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
const plugin = requireModule(name, {
|
|
|
|
paths: [
|
|
|
|
...nuxt.options.modulesDir,
|
|
|
|
distDir
|
|
|
|
]
|
|
|
|
})
|
|
|
|
// @ts-ignore
|
|
|
|
css.postcss.plugins.push(plugin(opts))
|
|
|
|
}
|
|
|
|
|
|
|
|
return css
|
|
|
|
}
|