@@ -2,6 +2,7 @@ import fs from 'fs'
2
2
import path from 'path'
3
3
import { Loader , Plugin , transform } from 'esbuild'
4
4
import { getPostcss } from '../utils'
5
+ import type { Result } from 'postcss-load-config' ;
5
6
6
7
export const postcssPlugin = ( {
7
8
css,
@@ -16,18 +17,18 @@ export const postcssPlugin = ({
16
17
name : 'postcss' ,
17
18
18
19
setup ( build ) {
19
- const configCache = new Map ( )
20
+ let configCache : Result
20
21
21
- const getPostcssConfig = async ( file : string ) => {
22
+ const getPostcssConfig = async ( ) => {
22
23
const loadConfig = require ( 'postcss-load-config' )
23
24
24
- if ( configCache . has ( file ) ) {
25
- return configCache . get ( file )
25
+ if ( configCache ) {
26
+ return configCache
26
27
}
27
28
28
29
try {
29
- const result = await loadConfig ( { } , path . dirname ( file ) )
30
- configCache . set ( file , result )
30
+ const result = await loadConfig ( { } , process . cwd ( ) )
31
+ configCache = result
31
32
return result
32
33
} catch ( error : any ) {
33
34
if ( error . message . includes ( 'No PostCSS Config found in' ) ) {
@@ -87,7 +88,7 @@ export const postcssPlugin = ({
87
88
}
88
89
89
90
// Load postcss config
90
- const { plugins, options } = await getPostcssConfig ( args . path )
91
+ const { plugins, options } = await getPostcssConfig ( )
91
92
92
93
if ( plugins && plugins . length > 0 ) {
93
94
// Load postcss
0 commit comments