File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
- export let postcss = require ( 'postcss' )
1
+ export function lazyPostcss ( ) {
2
+ return require ( 'postcss' )
3
+ }
2
4
3
5
export function lazyAutoprefixer ( ) {
4
6
return require ( 'autoprefixer' )
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
- import { postcss , lazyCssnano , lazyAutoprefixer } from '../peers/index.js'
3
+ import { lazyPostcss , lazyCssnano , lazyAutoprefixer } from '../peers/index.js'
4
4
5
5
import chokidar from 'chokidar'
6
6
import path from 'path'
@@ -146,6 +146,15 @@ function oneOf(...options) {
146
146
)
147
147
}
148
148
149
+ function loadPostcss ( ) {
150
+ // Try to load a local `postcss` version first
151
+ try {
152
+ return require ( 'postcss' )
153
+ } catch { }
154
+
155
+ return lazyPostcss ( )
156
+ }
157
+
149
158
let commands = {
150
159
init : {
151
160
run : init ,
@@ -576,6 +585,7 @@ async function build() {
576
585
} ) ( ) ,
577
586
] . filter ( Boolean )
578
587
588
+ let postcss = loadPostcss ( )
579
589
let processor = postcss ( plugins )
580
590
581
591
function processCSS ( css ) {
@@ -709,6 +719,7 @@ async function build() {
709
719
let tailwindPluginIdx = plugins . indexOf ( '__TAILWIND_PLUGIN_POSITION__' )
710
720
let copy = plugins . slice ( )
711
721
copy . splice ( tailwindPluginIdx , 1 , tailwindPlugin )
722
+ let postcss = loadPostcss ( )
712
723
let processor = postcss ( copy )
713
724
714
725
function processCSS ( css ) {
You can’t perform that action at this time.
0 commit comments