Skip to content

Commit 459dd22

Browse files
committed
ensure --content is taken into account
1 parent e8c3f08 commit 459dd22

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/cli/build/plugin.js

+29-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { parseCandidateFiles } from '../../lib/content.js'
1717
import { createWatcher } from './watching.js'
1818
import fastGlob from 'fast-glob'
1919
import { findAtConfigPath } from '../../lib/findAtConfigPath.js'
20+
import log from '../../util/log'
2021

2122
/**
2223
*
@@ -139,7 +140,7 @@ let state = {
139140
}
140141
},
141142

142-
loadConfig(configPath) {
143+
loadConfig(configPath, content) {
143144
if (this.watcher && configPath) {
144145
this.refreshConfigDependencies(configPath)
145146
}
@@ -149,6 +150,11 @@ let state = {
149150
// @ts-ignore
150151
config = resolveConfig(config, { content: { files: [] } })
151152

153+
// Override content files if `--content` has been passed explicitly
154+
if (content?.length > 0) {
155+
config.content.files = content
156+
}
157+
152158
return config
153159
},
154160

@@ -196,7 +202,7 @@ let state = {
196202
return content
197203
},
198204

199-
getContext({ createContext, cliConfigPath, root, result }) {
205+
getContext({ createContext, cliConfigPath, root, result, content }) {
200206
if (this.context) {
201207
this.context.changedContent = this.changedContent.splice(0)
202208

@@ -208,7 +214,7 @@ let state = {
208214
env.DEBUG && console.timeEnd('Searching for config')
209215

210216
env.DEBUG && console.time('Loading config')
211-
let config = this.loadConfig(configPath)
217+
let config = this.loadConfig(configPath, content)
212218
env.DEBUG && console.timeEnd('Loading config')
213219

214220
env.DEBUG && console.time('Creating context')
@@ -250,6 +256,19 @@ export async function createProcessor(args, cliConfigPath) {
250256
? await loadPostCssPlugins(customPostCssPath)
251257
: loadBuiltinPostcssPlugins()
252258

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+
253272
let tailwindPlugin = () => {
254273
return {
255274
postcssPlugin: 'tailwindcss',
@@ -260,7 +279,13 @@ export async function createProcessor(args, cliConfigPath) {
260279
console.error('Rebuilding...')
261280

262281
return () => {
263-
return state.getContext({ createContext, cliConfigPath, root, result })
282+
return state.getContext({
283+
createContext,
284+
cliConfigPath,
285+
root,
286+
result,
287+
content,
288+
})
264289
}
265290
})(root, result)
266291
env.DEBUG && console.timeEnd('Compiling CSS')

0 commit comments

Comments
 (0)