tailwindcss 0.0.0-oxide.6bf5e56 → 0.0.0-oxide.956419c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/lib/cli/index.js +231 -10
- package/lib/cli.js +4 -236
- package/lib/index.js +4 -46
- package/lib/lib/defaultExtractor.js +1 -1
- package/lib/oxide/cli.d.js +1 -0
- package/lib/oxide/cli.js +2 -0
- package/lib/oxide/postcss-plugin.d.js +1 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +48 -0
- package/package.json +8 -8
- package/src/cli/index.js +234 -3
- package/src/cli.js +4 -231
- package/src/index.js +4 -46
- package/src/lib/defaultExtractor.js +1 -1
- package/src/oxide/cli.d.ts +0 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.d.ts +0 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +47 -0
- package/stubs/defaultConfig.stub.js +145 -145
- package/types/generated/default-theme.d.ts +77 -77
package/src/cli/index.js
CHANGED
|
@@ -1,3 +1,234 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import arg from 'arg'
|
|
5
|
+
import fs from 'fs'
|
|
6
|
+
|
|
7
|
+
import { build } from './build'
|
|
8
|
+
import { help } from './help'
|
|
9
|
+
import { init } from './init'
|
|
10
|
+
|
|
11
|
+
function isESM() {
|
|
12
|
+
const pkgPath = path.resolve('./package.json')
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
16
|
+
return pkg.type && pkg.type === 'module'
|
|
17
|
+
} catch (err) {
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let configs = isESM()
|
|
23
|
+
? {
|
|
24
|
+
tailwind: 'tailwind.config.cjs',
|
|
25
|
+
postcss: 'postcss.config.cjs',
|
|
26
|
+
}
|
|
27
|
+
: {
|
|
28
|
+
tailwind: 'tailwind.config.js',
|
|
29
|
+
postcss: 'postcss.config.js',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ---
|
|
33
|
+
|
|
34
|
+
function oneOf(...options) {
|
|
35
|
+
return Object.assign(
|
|
36
|
+
(value = true) => {
|
|
37
|
+
for (let option of options) {
|
|
38
|
+
let parsed = option(value)
|
|
39
|
+
if (parsed === value) {
|
|
40
|
+
return parsed
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
throw new Error('...')
|
|
45
|
+
},
|
|
46
|
+
{ manualParsing: true }
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let commands = {
|
|
51
|
+
init: {
|
|
52
|
+
run: init,
|
|
53
|
+
args: {
|
|
54
|
+
'--full': { type: Boolean, description: `Initialize a full \`${configs.tailwind}\` file` },
|
|
55
|
+
'--postcss': { type: Boolean, description: `Initialize a \`${configs.postcss}\` file` },
|
|
56
|
+
'-f': '--full',
|
|
57
|
+
'-p': '--postcss',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
build: {
|
|
61
|
+
run: build,
|
|
62
|
+
args: {
|
|
63
|
+
'--input': { type: String, description: 'Input file' },
|
|
64
|
+
'--output': { type: String, description: 'Output file' },
|
|
65
|
+
'--watch': {
|
|
66
|
+
type: oneOf(String, Boolean),
|
|
67
|
+
description: 'Watch for changes and rebuild as needed',
|
|
68
|
+
},
|
|
69
|
+
'--poll': {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
description: 'Use polling instead of filesystem events when watching',
|
|
72
|
+
},
|
|
73
|
+
'--content': {
|
|
74
|
+
type: String,
|
|
75
|
+
description: 'Content paths to use for removing unused classes',
|
|
76
|
+
},
|
|
77
|
+
'--purge': {
|
|
78
|
+
type: String,
|
|
79
|
+
deprecated: true,
|
|
80
|
+
},
|
|
81
|
+
'--postcss': {
|
|
82
|
+
type: oneOf(String, Boolean),
|
|
83
|
+
description: 'Load custom PostCSS configuration',
|
|
84
|
+
},
|
|
85
|
+
'--minify': { type: Boolean, description: 'Minify the output' },
|
|
86
|
+
'--config': {
|
|
87
|
+
type: String,
|
|
88
|
+
description: 'Path to a custom config file',
|
|
89
|
+
},
|
|
90
|
+
'--no-autoprefixer': {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
description: 'Disable autoprefixer',
|
|
93
|
+
},
|
|
94
|
+
'-c': '--config',
|
|
95
|
+
'-i': '--input',
|
|
96
|
+
'-o': '--output',
|
|
97
|
+
'-m': '--minify',
|
|
98
|
+
'-w': '--watch',
|
|
99
|
+
'-p': '--poll',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let sharedFlags = {
|
|
105
|
+
'--help': { type: Boolean, description: 'Display usage information' },
|
|
106
|
+
'-h': '--help',
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
process.stdout.isTTY /* Detect redirecting output to a file */ &&
|
|
111
|
+
(process.argv[2] === undefined ||
|
|
112
|
+
process.argv.slice(2).every((flag) => sharedFlags[flag] !== undefined))
|
|
113
|
+
) {
|
|
114
|
+
help({
|
|
115
|
+
usage: [
|
|
116
|
+
'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
|
|
117
|
+
'tailwindcss init [--full] [--postcss] [options...]',
|
|
118
|
+
],
|
|
119
|
+
commands: Object.keys(commands)
|
|
120
|
+
.filter((command) => command !== 'build')
|
|
121
|
+
.map((command) => `${command} [options]`),
|
|
122
|
+
options: { ...commands.build.args, ...sharedFlags },
|
|
123
|
+
})
|
|
124
|
+
process.exit(0)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let command = ((arg = '') => (arg.startsWith('-') ? undefined : arg))(process.argv[2]) || 'build'
|
|
128
|
+
|
|
129
|
+
if (commands[command] === undefined) {
|
|
130
|
+
if (fs.existsSync(path.resolve(command))) {
|
|
131
|
+
// TODO: Deprecate this in future versions
|
|
132
|
+
// Check if non-existing command, might be a file.
|
|
133
|
+
command = 'build'
|
|
134
|
+
} else {
|
|
135
|
+
help({
|
|
136
|
+
message: `Invalid command: ${command}`,
|
|
137
|
+
usage: ['tailwindcss <command> [options]'],
|
|
138
|
+
commands: Object.keys(commands)
|
|
139
|
+
.filter((command) => command !== 'build')
|
|
140
|
+
.map((command) => `${command} [options]`),
|
|
141
|
+
options: sharedFlags,
|
|
142
|
+
})
|
|
143
|
+
process.exit(1)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Execute command
|
|
148
|
+
let { args: flags, run } = commands[command]
|
|
149
|
+
let args = (() => {
|
|
150
|
+
try {
|
|
151
|
+
let result = arg(
|
|
152
|
+
Object.fromEntries(
|
|
153
|
+
Object.entries({ ...flags, ...sharedFlags })
|
|
154
|
+
.filter(([_key, value]) => !value?.type?.manualParsing)
|
|
155
|
+
.map(([key, value]) => [key, typeof value === 'object' ? value.type : value])
|
|
156
|
+
),
|
|
157
|
+
{ permissive: true }
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
161
|
+
for (let i = result['_'].length - 1; i >= 0; --i) {
|
|
162
|
+
let flag = result['_'][i]
|
|
163
|
+
if (!flag.startsWith('-')) continue
|
|
164
|
+
|
|
165
|
+
let [flagName, flagValue] = flag.split('=')
|
|
166
|
+
let handler = flags[flagName]
|
|
167
|
+
|
|
168
|
+
// Resolve flagName & handler
|
|
169
|
+
while (typeof handler === 'string') {
|
|
170
|
+
flagName = handler
|
|
171
|
+
handler = flags[handler]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (!handler) continue
|
|
175
|
+
|
|
176
|
+
let args = []
|
|
177
|
+
let offset = i + 1
|
|
178
|
+
|
|
179
|
+
// --flag value syntax was used so we need to pull `value` from `args`
|
|
180
|
+
if (flagValue === undefined) {
|
|
181
|
+
// Parse args for current flag
|
|
182
|
+
while (result['_'][offset] && !result['_'][offset].startsWith('-')) {
|
|
183
|
+
args.push(result['_'][offset++])
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Cleanup manually parsed flags + args
|
|
187
|
+
result['_'].splice(i, 1 + args.length)
|
|
188
|
+
|
|
189
|
+
// No args were provided, use default value defined in handler
|
|
190
|
+
// One arg was provided, use that directly
|
|
191
|
+
// Multiple args were provided so pass them all in an array
|
|
192
|
+
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args
|
|
193
|
+
} else {
|
|
194
|
+
// Remove the whole flag from the args array
|
|
195
|
+
result['_'].splice(i, 1)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Set the resolved value in the `result` object
|
|
199
|
+
result[flagName] = handler.type(flagValue, flagName)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Ensure that the `command` is always the first argument in the `args`.
|
|
203
|
+
// This is important so that we don't have to check if a default command
|
|
204
|
+
// (build) was used or not from within each plugin.
|
|
205
|
+
//
|
|
206
|
+
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
|
207
|
+
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
|
208
|
+
if (result['_'][0] !== command) {
|
|
209
|
+
result['_'].unshift(command)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return result
|
|
213
|
+
} catch (err) {
|
|
214
|
+
if (err.code === 'ARG_UNKNOWN_OPTION') {
|
|
215
|
+
help({
|
|
216
|
+
message: err.message,
|
|
217
|
+
usage: ['tailwindcss <command> [options]'],
|
|
218
|
+
options: sharedFlags,
|
|
219
|
+
})
|
|
220
|
+
process.exit(1)
|
|
221
|
+
}
|
|
222
|
+
throw err
|
|
223
|
+
}
|
|
224
|
+
})()
|
|
225
|
+
|
|
226
|
+
if (args['--help']) {
|
|
227
|
+
help({
|
|
228
|
+
options: { ...flags, ...sharedFlags },
|
|
229
|
+
usage: [`tailwindcss ${command} [options]`],
|
|
230
|
+
})
|
|
231
|
+
process.exit(0)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
run(args, configs)
|
package/src/cli.js
CHANGED
|
@@ -1,234 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { build } from './cli/build'
|
|
8
|
-
import { help } from './cli/help'
|
|
9
|
-
import { init } from './cli/init'
|
|
10
|
-
|
|
11
|
-
function isESM() {
|
|
12
|
-
const pkgPath = path.resolve('./package.json')
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
16
|
-
return pkg.type && pkg.type === 'module'
|
|
17
|
-
} catch (err) {
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let configs = isESM()
|
|
23
|
-
? {
|
|
24
|
-
tailwind: 'tailwind.config.cjs',
|
|
25
|
-
postcss: 'postcss.config.cjs',
|
|
26
|
-
}
|
|
27
|
-
: {
|
|
28
|
-
tailwind: 'tailwind.config.js',
|
|
29
|
-
postcss: 'postcss.config.js',
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// ---
|
|
33
|
-
|
|
34
|
-
function oneOf(...options) {
|
|
35
|
-
return Object.assign(
|
|
36
|
-
(value = true) => {
|
|
37
|
-
for (let option of options) {
|
|
38
|
-
let parsed = option(value)
|
|
39
|
-
if (parsed === value) {
|
|
40
|
-
return parsed
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
throw new Error('...')
|
|
45
|
-
},
|
|
46
|
-
{ manualParsing: true }
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let commands = {
|
|
51
|
-
init: {
|
|
52
|
-
run: init,
|
|
53
|
-
args: {
|
|
54
|
-
'--full': { type: Boolean, description: `Initialize a full \`${configs.tailwind}\` file` },
|
|
55
|
-
'--postcss': { type: Boolean, description: `Initialize a \`${configs.postcss}\` file` },
|
|
56
|
-
'-f': '--full',
|
|
57
|
-
'-p': '--postcss',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
build: {
|
|
61
|
-
run: build,
|
|
62
|
-
args: {
|
|
63
|
-
'--input': { type: String, description: 'Input file' },
|
|
64
|
-
'--output': { type: String, description: 'Output file' },
|
|
65
|
-
'--watch': {
|
|
66
|
-
type: oneOf(String, Boolean),
|
|
67
|
-
description: 'Watch for changes and rebuild as needed',
|
|
68
|
-
},
|
|
69
|
-
'--poll': {
|
|
70
|
-
type: Boolean,
|
|
71
|
-
description: 'Use polling instead of filesystem events when watching',
|
|
72
|
-
},
|
|
73
|
-
'--content': {
|
|
74
|
-
type: String,
|
|
75
|
-
description: 'Content paths to use for removing unused classes',
|
|
76
|
-
},
|
|
77
|
-
'--purge': {
|
|
78
|
-
type: String,
|
|
79
|
-
deprecated: true,
|
|
80
|
-
},
|
|
81
|
-
'--postcss': {
|
|
82
|
-
type: oneOf(String, Boolean),
|
|
83
|
-
description: 'Load custom PostCSS configuration',
|
|
84
|
-
},
|
|
85
|
-
'--minify': { type: Boolean, description: 'Minify the output' },
|
|
86
|
-
'--config': {
|
|
87
|
-
type: String,
|
|
88
|
-
description: 'Path to a custom config file',
|
|
89
|
-
},
|
|
90
|
-
'--no-autoprefixer': {
|
|
91
|
-
type: Boolean,
|
|
92
|
-
description: 'Disable autoprefixer',
|
|
93
|
-
},
|
|
94
|
-
'-c': '--config',
|
|
95
|
-
'-i': '--input',
|
|
96
|
-
'-o': '--output',
|
|
97
|
-
'-m': '--minify',
|
|
98
|
-
'-w': '--watch',
|
|
99
|
-
'-p': '--poll',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let sharedFlags = {
|
|
105
|
-
'--help': { type: Boolean, description: 'Display usage information' },
|
|
106
|
-
'-h': '--help',
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
process.stdout.isTTY /* Detect redirecting output to a file */ &&
|
|
111
|
-
(process.argv[2] === undefined ||
|
|
112
|
-
process.argv.slice(2).every((flag) => sharedFlags[flag] !== undefined))
|
|
113
|
-
) {
|
|
114
|
-
help({
|
|
115
|
-
usage: [
|
|
116
|
-
'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]',
|
|
117
|
-
'tailwindcss init [--full] [--postcss] [options...]',
|
|
118
|
-
],
|
|
119
|
-
commands: Object.keys(commands)
|
|
120
|
-
.filter((command) => command !== 'build')
|
|
121
|
-
.map((command) => `${command} [options]`),
|
|
122
|
-
options: { ...commands.build.args, ...sharedFlags },
|
|
123
|
-
})
|
|
124
|
-
process.exit(0)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
let command = ((arg = '') => (arg.startsWith('-') ? undefined : arg))(process.argv[2]) || 'build'
|
|
128
|
-
|
|
129
|
-
if (commands[command] === undefined) {
|
|
130
|
-
if (fs.existsSync(path.resolve(command))) {
|
|
131
|
-
// TODO: Deprecate this in future versions
|
|
132
|
-
// Check if non-existing command, might be a file.
|
|
133
|
-
command = 'build'
|
|
134
|
-
} else {
|
|
135
|
-
help({
|
|
136
|
-
message: `Invalid command: ${command}`,
|
|
137
|
-
usage: ['tailwindcss <command> [options]'],
|
|
138
|
-
commands: Object.keys(commands)
|
|
139
|
-
.filter((command) => command !== 'build')
|
|
140
|
-
.map((command) => `${command} [options]`),
|
|
141
|
-
options: sharedFlags,
|
|
142
|
-
})
|
|
143
|
-
process.exit(1)
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Execute command
|
|
148
|
-
let { args: flags, run } = commands[command]
|
|
149
|
-
let args = (() => {
|
|
150
|
-
try {
|
|
151
|
-
let result = arg(
|
|
152
|
-
Object.fromEntries(
|
|
153
|
-
Object.entries({ ...flags, ...sharedFlags })
|
|
154
|
-
.filter(([_key, value]) => !value?.type?.manualParsing)
|
|
155
|
-
.map(([key, value]) => [key, typeof value === 'object' ? value.type : value])
|
|
156
|
-
),
|
|
157
|
-
{ permissive: true }
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
161
|
-
for (let i = result['_'].length - 1; i >= 0; --i) {
|
|
162
|
-
let flag = result['_'][i]
|
|
163
|
-
if (!flag.startsWith('-')) continue
|
|
164
|
-
|
|
165
|
-
let [flagName, flagValue] = flag.split('=')
|
|
166
|
-
let handler = flags[flagName]
|
|
167
|
-
|
|
168
|
-
// Resolve flagName & handler
|
|
169
|
-
while (typeof handler === 'string') {
|
|
170
|
-
flagName = handler
|
|
171
|
-
handler = flags[handler]
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (!handler) continue
|
|
175
|
-
|
|
176
|
-
let args = []
|
|
177
|
-
let offset = i + 1
|
|
178
|
-
|
|
179
|
-
// --flag value syntax was used so we need to pull `value` from `args`
|
|
180
|
-
if (flagValue === undefined) {
|
|
181
|
-
// Parse args for current flag
|
|
182
|
-
while (result['_'][offset] && !result['_'][offset].startsWith('-')) {
|
|
183
|
-
args.push(result['_'][offset++])
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Cleanup manually parsed flags + args
|
|
187
|
-
result['_'].splice(i, 1 + args.length)
|
|
188
|
-
|
|
189
|
-
// No args were provided, use default value defined in handler
|
|
190
|
-
// One arg was provided, use that directly
|
|
191
|
-
// Multiple args were provided so pass them all in an array
|
|
192
|
-
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args
|
|
193
|
-
} else {
|
|
194
|
-
// Remove the whole flag from the args array
|
|
195
|
-
result['_'].splice(i, 1)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Set the resolved value in the `result` object
|
|
199
|
-
result[flagName] = handler.type(flagValue, flagName)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Ensure that the `command` is always the first argument in the `args`.
|
|
203
|
-
// This is important so that we don't have to check if a default command
|
|
204
|
-
// (build) was used or not from within each plugin.
|
|
205
|
-
//
|
|
206
|
-
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
|
207
|
-
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
|
208
|
-
if (result['_'][0] !== command) {
|
|
209
|
-
result['_'].unshift(command)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return result
|
|
213
|
-
} catch (err) {
|
|
214
|
-
if (err.code === 'ARG_UNKNOWN_OPTION') {
|
|
215
|
-
help({
|
|
216
|
-
message: err.message,
|
|
217
|
-
usage: ['tailwindcss <command> [options]'],
|
|
218
|
-
options: sharedFlags,
|
|
219
|
-
})
|
|
220
|
-
process.exit(1)
|
|
221
|
-
}
|
|
222
|
-
throw err
|
|
223
|
-
}
|
|
224
|
-
})()
|
|
225
|
-
|
|
226
|
-
if (args['--help']) {
|
|
227
|
-
help({
|
|
228
|
-
options: { ...flags, ...sharedFlags },
|
|
229
|
-
usage: [`tailwindcss ${command} [options]`],
|
|
230
|
-
})
|
|
231
|
-
process.exit(0)
|
|
3
|
+
if (process.env.OXIDE) {
|
|
4
|
+
module.exports = require('./oxide/cli.js')
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require('./cli/index.js')
|
|
232
7
|
}
|
|
233
|
-
|
|
234
|
-
run(args, configs)
|
package/src/index.js
CHANGED
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module.exports = function tailwindcss(configOrPath) {
|
|
7
|
-
return {
|
|
8
|
-
postcssPlugin: 'tailwindcss',
|
|
9
|
-
plugins: [
|
|
10
|
-
env.DEBUG &&
|
|
11
|
-
function (root) {
|
|
12
|
-
console.log('\n')
|
|
13
|
-
console.time('JIT TOTAL')
|
|
14
|
-
return root
|
|
15
|
-
},
|
|
16
|
-
function (root, result) {
|
|
17
|
-
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
18
|
-
// path for the file being processed
|
|
19
|
-
configOrPath = findAtConfigPath(root, result) ?? configOrPath
|
|
20
|
-
|
|
21
|
-
let context = setupTrackingContext(configOrPath)
|
|
22
|
-
|
|
23
|
-
if (root.type === 'document') {
|
|
24
|
-
let roots = root.nodes.filter((node) => node.type === 'root')
|
|
25
|
-
|
|
26
|
-
for (const root of roots) {
|
|
27
|
-
if (root.type === 'root') {
|
|
28
|
-
processTailwindFeatures(context)(root, result)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
processTailwindFeatures(context)(root, result)
|
|
36
|
-
},
|
|
37
|
-
env.DEBUG &&
|
|
38
|
-
function (root) {
|
|
39
|
-
console.timeEnd('JIT TOTAL')
|
|
40
|
-
console.log('\n')
|
|
41
|
-
return root
|
|
42
|
-
},
|
|
43
|
-
].filter(Boolean),
|
|
44
|
-
}
|
|
1
|
+
if (process.env.OXIDE) {
|
|
2
|
+
module.exports = require('./oxide/postcss-plugin.js')
|
|
3
|
+
} else {
|
|
4
|
+
module.exports = require('./plugin.js')
|
|
45
5
|
}
|
|
46
|
-
|
|
47
|
-
module.exports.postcss = true
|
|
@@ -184,7 +184,7 @@ function clipAtBalancedParens(input) {
|
|
|
184
184
|
// This means that there was an extra closing `]`
|
|
185
185
|
// We'll clip to just before it
|
|
186
186
|
if (depth < 0) {
|
|
187
|
-
return input.substring(0, match.index)
|
|
187
|
+
return input.substring(0, match.index - 1)
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
// We've finished balancing the brackets but there still may be characters that can be included
|
|
File without changes
|
package/src/oxide/cli.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require('../cli/index.js')
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../plugin.js')
|
package/src/plugin.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import setupTrackingContext from './lib/setupTrackingContext'
|
|
2
|
+
import processTailwindFeatures from './processTailwindFeatures'
|
|
3
|
+
import { env } from './lib/sharedState'
|
|
4
|
+
import { findAtConfigPath } from './lib/findAtConfigPath'
|
|
5
|
+
|
|
6
|
+
module.exports = function tailwindcss(configOrPath) {
|
|
7
|
+
return {
|
|
8
|
+
postcssPlugin: 'tailwindcss',
|
|
9
|
+
plugins: [
|
|
10
|
+
env.DEBUG &&
|
|
11
|
+
function (root) {
|
|
12
|
+
console.log('\n')
|
|
13
|
+
console.time('JIT TOTAL')
|
|
14
|
+
return root
|
|
15
|
+
},
|
|
16
|
+
function (root, result) {
|
|
17
|
+
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
18
|
+
// path for the file being processed
|
|
19
|
+
configOrPath = findAtConfigPath(root, result) ?? configOrPath
|
|
20
|
+
|
|
21
|
+
let context = setupTrackingContext(configOrPath)
|
|
22
|
+
|
|
23
|
+
if (root.type === 'document') {
|
|
24
|
+
let roots = root.nodes.filter((node) => node.type === 'root')
|
|
25
|
+
|
|
26
|
+
for (const root of roots) {
|
|
27
|
+
if (root.type === 'root') {
|
|
28
|
+
processTailwindFeatures(context)(root, result)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
processTailwindFeatures(context)(root, result)
|
|
36
|
+
},
|
|
37
|
+
env.DEBUG &&
|
|
38
|
+
function (root) {
|
|
39
|
+
console.timeEnd('JIT TOTAL')
|
|
40
|
+
console.log('\n')
|
|
41
|
+
return root
|
|
42
|
+
},
|
|
43
|
+
].filter(Boolean),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports.postcss = true
|