@@ -9,6 +9,7 @@ import fs from 'fs'
99import postcssrc from 'postcss-load-config'
1010import { lilconfig } from 'lilconfig'
1111import loadPlugins from 'postcss-load-config/src/plugins' // Little bit scary, looking at private/internal API
12+ import loadOptions from 'postcss-load-config/src/options' // Little bit scary, looking at private/internal API
1213import tailwind from './processTailwindFeatures'
1314import resolveConfigInternal from '../resolveConfig'
1415import fastGlob from 'fast-glob'
@@ -415,7 +416,7 @@ async function build() {
415416
416417 async function loadPostCssPlugins ( ) {
417418 let customPostCssPath = typeof args [ '--postcss' ] === 'string' ? args [ '--postcss' ] : undefined
418- let { plugins : configPlugins } = customPostCssPath
419+ let config = customPostCssPath
419420 ? await ( async ( ) => {
420421 let file = path . resolve ( customPostCssPath )
421422
@@ -431,10 +432,16 @@ async function build() {
431432 config . plugins = [ ]
432433 }
433434
434- return { plugins : loadPlugins ( config , file ) }
435+ return {
436+ file,
437+ plugins : loadPlugins ( config , file ) ,
438+ options : loadOptions ( config , file ) ,
439+ }
435440 } ) ( )
436441 : await postcssrc ( )
437442
443+ let configPlugins = config . plugins
444+
438445 let configPluginTailwindIdx = configPlugins . findIndex ( ( plugin ) => {
439446 if ( typeof plugin === 'function' && plugin . name === 'tailwindcss' ) {
440447 return true
@@ -454,7 +461,7 @@ async function build() {
454461 ? configPlugins
455462 : configPlugins . slice ( configPluginTailwindIdx + 1 )
456463
457- return [ beforePlugins , afterPlugins ]
464+ return [ beforePlugins , afterPlugins , config . options ]
458465 }
459466
460467 function resolveConfig ( ) {
@@ -538,7 +545,9 @@ async function build() {
538545
539546 tailwindPlugin . postcss = true
540547
541- let [ beforePlugins , afterPlugins ] = includePostCss ? await loadPostCssPlugins ( ) : [ [ ] , [ ] ]
548+ let [ beforePlugins , afterPlugins , postcssOptions ] = includePostCss
549+ ? await loadPostCssPlugins ( )
550+ : [ [ ] , [ ] , { } ]
542551
543552 let plugins = [
544553 ...beforePlugins ,
@@ -573,7 +582,7 @@ async function build() {
573582 let start = process . hrtime . bigint ( )
574583 return Promise . resolve ( )
575584 . then ( ( ) => ( output ? fs . promises . mkdir ( path . dirname ( output ) , { recursive : true } ) : null ) )
576- . then ( ( ) => processor . process ( css , { from : input , to : output } ) )
585+ . then ( ( ) => processor . process ( css , { ... postcssOptions , from : input , to : output } ) )
577586 . then ( ( result ) => {
578587 if ( ! output ) {
579588 return process . stdout . write ( result . css )
0 commit comments