@@ -9,6 +9,7 @@ import fs from 'fs'
9
9
import postcssrc from 'postcss-load-config'
10
10
import { lilconfig } from 'lilconfig'
11
11
import 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
12
13
import tailwind from './processTailwindFeatures'
13
14
import resolveConfigInternal from '../resolveConfig'
14
15
import fastGlob from 'fast-glob'
@@ -415,7 +416,7 @@ async function build() {
415
416
416
417
async function loadPostCssPlugins ( ) {
417
418
let customPostCssPath = typeof args [ '--postcss' ] === 'string' ? args [ '--postcss' ] : undefined
418
- let { plugins : configPlugins } = customPostCssPath
419
+ let config = customPostCssPath
419
420
? await ( async ( ) => {
420
421
let file = path . resolve ( customPostCssPath )
421
422
@@ -431,10 +432,16 @@ async function build() {
431
432
config . plugins = [ ]
432
433
}
433
434
434
- return { plugins : loadPlugins ( config , file ) }
435
+ return {
436
+ file,
437
+ plugins : loadPlugins ( config , file ) ,
438
+ options : loadOptions ( config , file ) ,
439
+ }
435
440
} ) ( )
436
441
: await postcssrc ( )
437
442
443
+ let configPlugins = config . plugins
444
+
438
445
let configPluginTailwindIdx = configPlugins . findIndex ( ( plugin ) => {
439
446
if ( typeof plugin === 'function' && plugin . name === 'tailwindcss' ) {
440
447
return true
@@ -454,7 +461,7 @@ async function build() {
454
461
? configPlugins
455
462
: configPlugins . slice ( configPluginTailwindIdx + 1 )
456
463
457
- return [ beforePlugins , afterPlugins ]
464
+ return [ beforePlugins , afterPlugins , config . options ]
458
465
}
459
466
460
467
function resolveConfig ( ) {
@@ -538,7 +545,9 @@ async function build() {
538
545
539
546
tailwindPlugin . postcss = true
540
547
541
- let [ beforePlugins , afterPlugins ] = includePostCss ? await loadPostCssPlugins ( ) : [ [ ] , [ ] ]
548
+ let [ beforePlugins , afterPlugins , postcssOptions ] = includePostCss
549
+ ? await loadPostCssPlugins ( )
550
+ : [ [ ] , [ ] , { } ]
542
551
543
552
let plugins = [
544
553
...beforePlugins ,
@@ -573,7 +582,7 @@ async function build() {
573
582
let start = process . hrtime . bigint ( )
574
583
return Promise . resolve ( )
575
584
. 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 } ) )
577
586
. then ( ( result ) => {
578
587
if ( ! output ) {
579
588
return process . stdout . write ( result . css )
0 commit comments