@@ -17,6 +17,7 @@ import { parseCandidateFiles } from '../../lib/content.js'
17
17
import { createWatcher } from './watching.js'
18
18
import fastGlob from 'fast-glob'
19
19
import { findAtConfigPath } from '../../lib/findAtConfigPath.js'
20
+ import log from '../../util/log'
20
21
21
22
/**
22
23
*
@@ -139,7 +140,7 @@ let state = {
139
140
}
140
141
} ,
141
142
142
- loadConfig ( configPath ) {
143
+ loadConfig ( configPath , content ) {
143
144
if ( this . watcher && configPath ) {
144
145
this . refreshConfigDependencies ( configPath )
145
146
}
@@ -149,6 +150,11 @@ let state = {
149
150
// @ts -ignore
150
151
config = resolveConfig ( config , { content : { files : [ ] } } )
151
152
153
+ // Override content files if `--content` has been passed explicitly
154
+ if ( content ?. length > 0 ) {
155
+ config . content . files = content
156
+ }
157
+
152
158
return config
153
159
} ,
154
160
@@ -196,7 +202,7 @@ let state = {
196
202
return content
197
203
} ,
198
204
199
- getContext ( { createContext, cliConfigPath, root, result } ) {
205
+ getContext ( { createContext, cliConfigPath, root, result, content } ) {
200
206
if ( this . context ) {
201
207
this . context . changedContent = this . changedContent . splice ( 0 )
202
208
@@ -208,7 +214,7 @@ let state = {
208
214
env . DEBUG && console . timeEnd ( 'Searching for config' )
209
215
210
216
env . DEBUG && console . time ( 'Loading config' )
211
- let config = this . loadConfig ( configPath )
217
+ let config = this . loadConfig ( configPath , content )
212
218
env . DEBUG && console . timeEnd ( 'Loading config' )
213
219
214
220
env . DEBUG && console . time ( 'Creating context' )
@@ -250,6 +256,19 @@ export async function createProcessor(args, cliConfigPath) {
250
256
? await loadPostCssPlugins ( customPostCssPath )
251
257
: loadBuiltinPostcssPlugins ( )
252
258
259
+ if ( args [ '--purge' ] ) {
260
+ log . warn ( 'purge-flag-deprecated' , [
261
+ 'The `--purge` flag has been deprecated.' ,
262
+ 'Please use `--content` instead.' ,
263
+ ] )
264
+
265
+ if ( ! args [ '--content' ] ) {
266
+ args [ '--content' ] = args [ '--purge' ]
267
+ }
268
+ }
269
+
270
+ let content = args [ '--content' ] ?. split ( / (?< ! { [ ^ } ] + ) , / ) ?? [ ]
271
+
253
272
let tailwindPlugin = ( ) => {
254
273
return {
255
274
postcssPlugin : 'tailwindcss' ,
@@ -260,7 +279,13 @@ export async function createProcessor(args, cliConfigPath) {
260
279
console . error ( 'Rebuilding...' )
261
280
262
281
return ( ) => {
263
- return state . getContext ( { createContext, cliConfigPath, root, result } )
282
+ return state . getContext ( {
283
+ createContext,
284
+ cliConfigPath,
285
+ root,
286
+ result,
287
+ content,
288
+ } )
264
289
}
265
290
} ) ( root , result )
266
291
env . DEBUG && console . timeEnd ( 'Compiling CSS' )
0 commit comments