tailwindcss 0.0.0-insiders.fe08e91 → 0.0.0-oxide.6bf5e56
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 +379 -3
- package/LICENSE +1 -2
- package/README.md +12 -8
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +367 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +13 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +107 -611
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +6 -3
- package/lib/corePlugins.js +2064 -1811
- package/lib/css/preflight.css +5 -5
- package/lib/featureFlags.js +31 -22
- package/lib/index.js +28 -10
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +12 -9
- package/lib/lib/content.js +176 -0
- package/lib/lib/defaultExtractor.js +225 -31
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +118 -55
- package/lib/lib/expandApplyAtRules.js +439 -190
- package/lib/lib/expandTailwindAtRules.js +151 -134
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +454 -187
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +36 -32
- package/lib/lib/offsets.js +217 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +89 -67
- package/lib/lib/setupContextUtils.js +667 -376
- package/lib/lib/setupTrackingContext.js +38 -67
- package/lib/lib/sharedState.js +27 -14
- package/lib/lib/substituteScreenAtRules.js +11 -9
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +35 -25
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +11 -6
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +53 -54
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -110
- package/lib/util/defaults.js +4 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +184 -85
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +23 -15
- package/lib/util/log.js +20 -14
- package/lib/util/nameClass.js +20 -9
- package/lib/util/negateValue.js +23 -8
- package/lib/util/normalizeConfig.js +116 -72
- package/lib/util/normalizeScreens.js +120 -11
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +147 -50
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +97 -85
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +20 -4
- package/lib/util/transformThemeValue.js +37 -29
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +47 -42
- package/peers/index.js +11381 -7950
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +12 -0
- package/scripts/generate-types.js +105 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +439 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +6 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +50 -629
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +532 -217
- package/src/css/preflight.css +5 -5
- package/src/featureFlags.js +15 -9
- package/src/index.js +20 -1
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/content.js +212 -0
- package/src/lib/defaultExtractor.js +196 -33
- package/src/lib/evaluateTailwindFunctions.js +78 -7
- package/src/lib/expandApplyAtRules.js +482 -183
- package/src/lib/expandTailwindAtRules.js +106 -85
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +418 -129
- package/src/lib/normalizeTailwindDirectives.js +1 -0
- package/src/lib/offsets.js +270 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +51 -30
- package/src/lib/setupContextUtils.js +556 -208
- package/src/lib/setupTrackingContext.js +11 -48
- package/src/lib/sharedState.js +5 -0
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +8 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +25 -21
- package/src/util/dataTypes.js +29 -21
- package/src/util/formatVariantSelector.js +184 -61
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +8 -8
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +44 -6
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +132 -10
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -32
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +23 -20
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +362 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/nesting/plugin.js +0 -41
package/lib/cli.js
CHANGED
|
@@ -1,121 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
=
|
|
12
|
-
var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
|
|
13
|
-
var _resolveConfig = _interopRequireDefault(require("../resolveConfig"));
|
|
14
|
-
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
15
|
-
var _getModuleDependencies = _interopRequireDefault(require("./lib/getModuleDependencies"));
|
|
16
|
-
var _log = _interopRequireDefault(require("./util/log"));
|
|
17
|
-
var _packageJson = _interopRequireDefault(require("../package.json"));
|
|
18
|
-
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
7
|
+
const _arg = /*#__PURE__*/ _interopRequireDefault(require("arg"));
|
|
8
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
9
|
+
const _build = require("./cli/build");
|
|
10
|
+
const _help = require("./cli/help");
|
|
11
|
+
const _init = require("./cli/init");
|
|
19
12
|
function _interopRequireDefault(obj) {
|
|
20
13
|
return obj && obj.__esModule ? obj : {
|
|
21
14
|
default: obj
|
|
22
15
|
};
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`;
|
|
32
|
-
}
|
|
33
|
-
child.raws.after = `\n${' '.repeat(indent)}`;
|
|
34
|
-
indentRecursive(child, indent + 1);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function formatNodes(root) {
|
|
38
|
-
indentRecursive(root);
|
|
39
|
-
if (root.first) {
|
|
40
|
-
root.first.raws.before = '';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async function outputFile(file, contents) {
|
|
44
|
-
if (_fs.default.existsSync(file) && await _fs.default.promises.readFile(file, 'utf8') === contents) {
|
|
45
|
-
return; // Skip writing the file
|
|
46
|
-
}
|
|
47
|
-
// Write the file
|
|
48
|
-
await _fs.default.promises.writeFile(file, contents, 'utf8');
|
|
49
|
-
}
|
|
50
|
-
function drainStdin() {
|
|
51
|
-
return new Promise((resolve, reject)=>{
|
|
52
|
-
let result = '';
|
|
53
|
-
process.stdin.on('data', (chunk)=>{
|
|
54
|
-
result += chunk;
|
|
55
|
-
});
|
|
56
|
-
process.stdin.on('end', ()=>resolve(result)
|
|
57
|
-
);
|
|
58
|
-
process.stdin.on('error', (err)=>reject(err)
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function help({ message , usage , commands: commands1 , options }) {
|
|
63
|
-
let indent = 2;
|
|
64
|
-
// Render header
|
|
65
|
-
console.log();
|
|
66
|
-
console.log(`${_packageJson.default.name} v${_packageJson.default.version}`);
|
|
67
|
-
// Render message
|
|
68
|
-
if (message) {
|
|
69
|
-
console.log();
|
|
70
|
-
for (let msg of message.split('\n')){
|
|
71
|
-
console.log(msg);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Render usage
|
|
75
|
-
if (usage && usage.length > 0) {
|
|
76
|
-
console.log();
|
|
77
|
-
console.log('Usage:');
|
|
78
|
-
for (let example of usage){
|
|
79
|
-
console.log(' '.repeat(indent), example);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Render commands
|
|
83
|
-
if (commands1 && commands1.length > 0) {
|
|
84
|
-
console.log();
|
|
85
|
-
console.log('Commands:');
|
|
86
|
-
for (let command1 of commands1){
|
|
87
|
-
console.log(' '.repeat(indent), command1);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// Render options
|
|
91
|
-
if (options) {
|
|
92
|
-
let groupedOptions = {
|
|
93
|
-
};
|
|
94
|
-
for (let [key, value] of Object.entries(options)){
|
|
95
|
-
if (typeof value === 'object') {
|
|
96
|
-
groupedOptions[key] = {
|
|
97
|
-
...value,
|
|
98
|
-
flags: [
|
|
99
|
-
key
|
|
100
|
-
]
|
|
101
|
-
};
|
|
102
|
-
} else {
|
|
103
|
-
groupedOptions[value].flags.push(key);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
console.log();
|
|
107
|
-
console.log('Options:');
|
|
108
|
-
for (let { flags: flags1 , description , deprecated } of Object.values(groupedOptions)){
|
|
109
|
-
if (deprecated) continue;
|
|
110
|
-
if (flags1.length === 1) {
|
|
111
|
-
console.log(' '.repeat(indent + 4 /* 4 = "-i, ".length */ ), flags1.slice().reverse().join(', ').padEnd(20, ' '), description);
|
|
112
|
-
} else {
|
|
113
|
-
console.log(' '.repeat(indent), flags1.slice().reverse().join(', ').padEnd(24, ' '), description);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
17
|
+
function isESM() {
|
|
18
|
+
const pkgPath = _path.default.resolve("./package.json");
|
|
19
|
+
try {
|
|
20
|
+
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
21
|
+
return pkg.type && pkg.type === "module";
|
|
22
|
+
} catch (err) {
|
|
23
|
+
return false;
|
|
116
24
|
}
|
|
117
|
-
console.log();
|
|
118
25
|
}
|
|
26
|
+
let configs = isESM() ? {
|
|
27
|
+
tailwind: "tailwind.config.cjs",
|
|
28
|
+
postcss: "postcss.config.cjs"
|
|
29
|
+
} : {
|
|
30
|
+
tailwind: "tailwind.config.js",
|
|
31
|
+
postcss: "postcss.config.js"
|
|
32
|
+
};
|
|
33
|
+
// ---
|
|
119
34
|
function oneOf(...options) {
|
|
120
35
|
return Object.assign((value = true)=>{
|
|
121
36
|
for (let option of options){
|
|
@@ -124,91 +39,93 @@ function oneOf(...options) {
|
|
|
124
39
|
return parsed;
|
|
125
40
|
}
|
|
126
41
|
}
|
|
127
|
-
throw new Error(
|
|
42
|
+
throw new Error("...");
|
|
128
43
|
}, {
|
|
129
44
|
manualParsing: true
|
|
130
45
|
});
|
|
131
46
|
}
|
|
132
47
|
let commands = {
|
|
133
48
|
init: {
|
|
134
|
-
run: init,
|
|
49
|
+
run: _init.init,
|
|
135
50
|
args: {
|
|
136
|
-
|
|
51
|
+
"--full": {
|
|
137
52
|
type: Boolean,
|
|
138
|
-
description:
|
|
53
|
+
description: `Initialize a full \`${configs.tailwind}\` file`
|
|
139
54
|
},
|
|
140
|
-
|
|
55
|
+
"--postcss": {
|
|
141
56
|
type: Boolean,
|
|
142
|
-
description:
|
|
57
|
+
description: `Initialize a \`${configs.postcss}\` file`
|
|
143
58
|
},
|
|
144
|
-
|
|
145
|
-
|
|
59
|
+
"-f": "--full",
|
|
60
|
+
"-p": "--postcss"
|
|
146
61
|
}
|
|
147
62
|
},
|
|
148
63
|
build: {
|
|
149
|
-
run: build,
|
|
64
|
+
run: _build.build,
|
|
150
65
|
args: {
|
|
151
|
-
|
|
66
|
+
"--input": {
|
|
152
67
|
type: String,
|
|
153
|
-
description:
|
|
68
|
+
description: "Input file"
|
|
154
69
|
},
|
|
155
|
-
|
|
70
|
+
"--output": {
|
|
156
71
|
type: String,
|
|
157
|
-
description:
|
|
72
|
+
description: "Output file"
|
|
73
|
+
},
|
|
74
|
+
"--watch": {
|
|
75
|
+
type: oneOf(String, Boolean),
|
|
76
|
+
description: "Watch for changes and rebuild as needed"
|
|
158
77
|
},
|
|
159
|
-
|
|
78
|
+
"--poll": {
|
|
160
79
|
type: Boolean,
|
|
161
|
-
description:
|
|
80
|
+
description: "Use polling instead of filesystem events when watching"
|
|
162
81
|
},
|
|
163
|
-
|
|
82
|
+
"--content": {
|
|
164
83
|
type: String,
|
|
165
|
-
description:
|
|
84
|
+
description: "Content paths to use for removing unused classes"
|
|
166
85
|
},
|
|
167
|
-
|
|
86
|
+
"--purge": {
|
|
168
87
|
type: String,
|
|
169
88
|
deprecated: true
|
|
170
89
|
},
|
|
171
|
-
|
|
90
|
+
"--postcss": {
|
|
172
91
|
type: oneOf(String, Boolean),
|
|
173
|
-
description:
|
|
92
|
+
description: "Load custom PostCSS configuration"
|
|
174
93
|
},
|
|
175
|
-
|
|
94
|
+
"--minify": {
|
|
176
95
|
type: Boolean,
|
|
177
|
-
description:
|
|
96
|
+
description: "Minify the output"
|
|
178
97
|
},
|
|
179
|
-
|
|
98
|
+
"--config": {
|
|
180
99
|
type: String,
|
|
181
|
-
description:
|
|
100
|
+
description: "Path to a custom config file"
|
|
182
101
|
},
|
|
183
|
-
|
|
102
|
+
"--no-autoprefixer": {
|
|
184
103
|
type: Boolean,
|
|
185
|
-
description:
|
|
104
|
+
description: "Disable autoprefixer"
|
|
186
105
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
106
|
+
"-c": "--config",
|
|
107
|
+
"-i": "--input",
|
|
108
|
+
"-o": "--output",
|
|
109
|
+
"-m": "--minify",
|
|
110
|
+
"-w": "--watch",
|
|
111
|
+
"-p": "--poll"
|
|
192
112
|
}
|
|
193
113
|
}
|
|
194
114
|
};
|
|
195
115
|
let sharedFlags = {
|
|
196
|
-
|
|
116
|
+
"--help": {
|
|
197
117
|
type: Boolean,
|
|
198
|
-
description:
|
|
118
|
+
description: "Display usage information"
|
|
199
119
|
},
|
|
200
|
-
|
|
120
|
+
"-h": "--help"
|
|
201
121
|
};
|
|
202
|
-
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined
|
|
203
|
-
)
|
|
204
|
-
help({
|
|
122
|
+
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
|
123
|
+
(0, _help.help)({
|
|
205
124
|
usage: [
|
|
206
|
-
|
|
207
|
-
|
|
125
|
+
"tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
|
|
126
|
+
"tailwindcss init [--full] [--postcss] [options...]"
|
|
208
127
|
],
|
|
209
|
-
commands: Object.keys(commands).filter((
|
|
210
|
-
).map((command3)=>`${command3} [options]`
|
|
211
|
-
),
|
|
128
|
+
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
|
212
129
|
options: {
|
|
213
130
|
...commands.build.args,
|
|
214
131
|
...sharedFlags
|
|
@@ -216,22 +133,19 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
|
|
|
216
133
|
});
|
|
217
134
|
process.exit(0);
|
|
218
135
|
}
|
|
219
|
-
let command = ((arg =
|
|
220
|
-
)(process.argv[2]) || 'build';
|
|
136
|
+
let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
|
|
221
137
|
if (commands[command] === undefined) {
|
|
222
138
|
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
|
223
139
|
// TODO: Deprecate this in future versions
|
|
224
140
|
// Check if non-existing command, might be a file.
|
|
225
|
-
command =
|
|
141
|
+
command = "build";
|
|
226
142
|
} else {
|
|
227
|
-
help({
|
|
143
|
+
(0, _help.help)({
|
|
228
144
|
message: `Invalid command: ${command}`,
|
|
229
145
|
usage: [
|
|
230
|
-
|
|
146
|
+
"tailwindcss <command> [options]"
|
|
231
147
|
],
|
|
232
|
-
commands: Object.keys(commands).filter((
|
|
233
|
-
).map((command5)=>`${command5} [options]`
|
|
234
|
-
),
|
|
148
|
+
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
|
235
149
|
options: sharedFlags
|
|
236
150
|
});
|
|
237
151
|
process.exit(1);
|
|
@@ -241,7 +155,7 @@ if (commands[command] === undefined) {
|
|
|
241
155
|
let { args: flags , run } = commands[command];
|
|
242
156
|
let args = (()=>{
|
|
243
157
|
try {
|
|
244
|
-
let result = (0, _arg
|
|
158
|
+
let result = (0, _arg.default)(Object.fromEntries(Object.entries({
|
|
245
159
|
...flags,
|
|
246
160
|
...sharedFlags
|
|
247
161
|
}).filter(([_key, value])=>{
|
|
@@ -249,33 +163,42 @@ let args = (()=>{
|
|
|
249
163
|
return !(value === null || value === void 0 ? void 0 : (ref = value.type) === null || ref === void 0 ? void 0 : ref.manualParsing);
|
|
250
164
|
}).map(([key, value])=>[
|
|
251
165
|
key,
|
|
252
|
-
typeof value ===
|
|
253
|
-
]
|
|
254
|
-
)), {
|
|
166
|
+
typeof value === "object" ? value.type : value
|
|
167
|
+
])), {
|
|
255
168
|
permissive: true
|
|
256
169
|
});
|
|
257
170
|
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
258
|
-
for(let i = result[
|
|
259
|
-
let flag = result[
|
|
260
|
-
if (!flag.startsWith(
|
|
261
|
-
let flagName = flag;
|
|
262
|
-
let handler = flags[
|
|
171
|
+
for(let i = result["_"].length - 1; i >= 0; --i){
|
|
172
|
+
let flag = result["_"][i];
|
|
173
|
+
if (!flag.startsWith("-")) continue;
|
|
174
|
+
let [flagName, flagValue] = flag.split("=");
|
|
175
|
+
let handler = flags[flagName];
|
|
263
176
|
// Resolve flagName & handler
|
|
264
|
-
while(typeof handler ===
|
|
177
|
+
while(typeof handler === "string"){
|
|
265
178
|
flagName = handler;
|
|
266
179
|
handler = flags[handler];
|
|
267
180
|
}
|
|
268
181
|
if (!handler) continue;
|
|
269
|
-
let
|
|
182
|
+
let args = [];
|
|
270
183
|
let offset = i + 1;
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
|
|
184
|
+
// --flag value syntax was used so we need to pull `value` from `args`
|
|
185
|
+
if (flagValue === undefined) {
|
|
186
|
+
// Parse args for current flag
|
|
187
|
+
while(result["_"][offset] && !result["_"][offset].startsWith("-")){
|
|
188
|
+
args.push(result["_"][offset++]);
|
|
189
|
+
}
|
|
190
|
+
// Cleanup manually parsed flags + args
|
|
191
|
+
result["_"].splice(i, 1 + args.length);
|
|
192
|
+
// No args were provided, use default value defined in handler
|
|
193
|
+
// One arg was provided, use that directly
|
|
194
|
+
// Multiple args were provided so pass them all in an array
|
|
195
|
+
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
|
|
196
|
+
} else {
|
|
197
|
+
// Remove the whole flag from the args array
|
|
198
|
+
result["_"].splice(i, 1);
|
|
274
199
|
}
|
|
275
|
-
// Cleanup manually parsed flags + args
|
|
276
|
-
result['_'].splice(i, 1 + args1.length);
|
|
277
200
|
// Set the resolved value in the `result` object
|
|
278
|
-
result[flagName] = handler.type(
|
|
201
|
+
result[flagName] = handler.type(flagValue, flagName);
|
|
279
202
|
}
|
|
280
203
|
// Ensure that the `command` is always the first argument in the `args`.
|
|
281
204
|
// This is important so that we don't have to check if a default command
|
|
@@ -283,16 +206,16 @@ let args = (()=>{
|
|
|
283
206
|
//
|
|
284
207
|
// E.g.: tailwindcss input.css -> _: ['build', 'input.css']
|
|
285
208
|
// E.g.: tailwindcss build input.css -> _: ['build', 'input.css']
|
|
286
|
-
if (result[
|
|
287
|
-
result[
|
|
209
|
+
if (result["_"][0] !== command) {
|
|
210
|
+
result["_"].unshift(command);
|
|
288
211
|
}
|
|
289
212
|
return result;
|
|
290
213
|
} catch (err) {
|
|
291
|
-
if (err.code ===
|
|
292
|
-
help({
|
|
214
|
+
if (err.code === "ARG_UNKNOWN_OPTION") {
|
|
215
|
+
(0, _help.help)({
|
|
293
216
|
message: err.message,
|
|
294
217
|
usage: [
|
|
295
|
-
|
|
218
|
+
"tailwindcss <command> [options]"
|
|
296
219
|
],
|
|
297
220
|
options: sharedFlags
|
|
298
221
|
});
|
|
@@ -301,8 +224,8 @@ let args = (()=>{
|
|
|
301
224
|
throw err;
|
|
302
225
|
}
|
|
303
226
|
})();
|
|
304
|
-
if (args[
|
|
305
|
-
help({
|
|
227
|
+
if (args["--help"]) {
|
|
228
|
+
(0, _help.help)({
|
|
306
229
|
options: {
|
|
307
230
|
...flags,
|
|
308
231
|
...sharedFlags
|
|
@@ -313,431 +236,4 @@ if (args['--help']) {
|
|
|
313
236
|
});
|
|
314
237
|
process.exit(0);
|
|
315
238
|
}
|
|
316
|
-
run();
|
|
317
|
-
// ---
|
|
318
|
-
function init() {
|
|
319
|
-
let messages = [];
|
|
320
|
-
var ref;
|
|
321
|
-
let tailwindConfigLocation = _path.default.resolve((ref = args['_'][1]) !== null && ref !== void 0 ? ref : './tailwind.config.js');
|
|
322
|
-
if (_fs.default.existsSync(tailwindConfigLocation)) {
|
|
323
|
-
messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
|
|
324
|
-
} else {
|
|
325
|
-
let stubFile = _fs.default.readFileSync(args['--full'] ? _path.default.resolve(__dirname, '../stubs/defaultConfig.stub.js') : _path.default.resolve(__dirname, '../stubs/simpleConfig.stub.js'), 'utf8');
|
|
326
|
-
// Change colors import
|
|
327
|
-
stubFile = stubFile.replace('../colors', 'tailwindcss/colors');
|
|
328
|
-
_fs.default.writeFileSync(tailwindConfigLocation, stubFile, 'utf8');
|
|
329
|
-
messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
|
|
330
|
-
}
|
|
331
|
-
if (args['--postcss']) {
|
|
332
|
-
let postcssConfigLocation = _path.default.resolve('./postcss.config.js');
|
|
333
|
-
if (_fs.default.existsSync(postcssConfigLocation)) {
|
|
334
|
-
messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
|
|
335
|
-
} else {
|
|
336
|
-
let stubFile = _fs.default.readFileSync(_path.default.resolve(__dirname, '../stubs/defaultPostCssConfig.stub.js'), 'utf8');
|
|
337
|
-
_fs.default.writeFileSync(postcssConfigLocation, stubFile, 'utf8');
|
|
338
|
-
messages.push(`Created PostCSS config file: ${_path.default.basename(postcssConfigLocation)}`);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
if (messages.length > 0) {
|
|
342
|
-
console.log();
|
|
343
|
-
for (let message of messages){
|
|
344
|
-
console.log(message);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
async function build() {
|
|
349
|
-
let input = args['--input'];
|
|
350
|
-
let output = args['--output'];
|
|
351
|
-
let shouldWatch = args['--watch'];
|
|
352
|
-
let includePostCss = args['--postcss'];
|
|
353
|
-
// TODO: Deprecate this in future versions
|
|
354
|
-
if (!input && args['_'][1]) {
|
|
355
|
-
console.error('[deprecation] Running tailwindcss without -i, please provide an input file.');
|
|
356
|
-
input = args['--input'] = args['_'][1];
|
|
357
|
-
}
|
|
358
|
-
if (input && input !== '-' && !_fs.default.existsSync(input = _path.default.resolve(input))) {
|
|
359
|
-
console.error(`Specified input file ${args['--input']} does not exist.`);
|
|
360
|
-
process.exit(9);
|
|
361
|
-
}
|
|
362
|
-
if (args['--config'] && !_fs.default.existsSync(args['--config'] = _path.default.resolve(args['--config']))) {
|
|
363
|
-
console.error(`Specified config file ${args['--config']} does not exist.`);
|
|
364
|
-
process.exit(9);
|
|
365
|
-
}
|
|
366
|
-
let configPath = args['--config'] ? args['--config'] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null
|
|
367
|
-
)(_path.default.resolve('./tailwind.config.js'));
|
|
368
|
-
async function loadPostCssPlugins() {
|
|
369
|
-
let customPostCssPath = typeof args['--postcss'] === 'string' ? args['--postcss'] : undefined;
|
|
370
|
-
let { plugins: configPlugins } = customPostCssPath ? await (async ()=>{
|
|
371
|
-
let file = _path.default.resolve(customPostCssPath);
|
|
372
|
-
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.0.1/src/index.js
|
|
373
|
-
let { config ={
|
|
374
|
-
} } = await (0, _cosmiconfig).cosmiconfig('postcss').load(file);
|
|
375
|
-
if (typeof config === 'function') {
|
|
376
|
-
config = config();
|
|
377
|
-
} else {
|
|
378
|
-
config = Object.assign({
|
|
379
|
-
}, config);
|
|
380
|
-
}
|
|
381
|
-
if (!config.plugins) {
|
|
382
|
-
config.plugins = [];
|
|
383
|
-
}
|
|
384
|
-
return {
|
|
385
|
-
plugins: (0, _plugins).default(config, file)
|
|
386
|
-
};
|
|
387
|
-
})() : await (0, _postcssLoadConfig).default();
|
|
388
|
-
let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
|
|
389
|
-
if (typeof plugin === 'function' && plugin.name === 'tailwindcss') {
|
|
390
|
-
return true;
|
|
391
|
-
}
|
|
392
|
-
if (typeof plugin === 'object' && plugin !== null && plugin.postcssPlugin === 'tailwindcss') {
|
|
393
|
-
return true;
|
|
394
|
-
}
|
|
395
|
-
return false;
|
|
396
|
-
});
|
|
397
|
-
let beforePlugins = configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx);
|
|
398
|
-
let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
|
|
399
|
-
return [
|
|
400
|
-
beforePlugins,
|
|
401
|
-
afterPlugins
|
|
402
|
-
];
|
|
403
|
-
}
|
|
404
|
-
function resolveConfig() {
|
|
405
|
-
let config = configPath ? require(configPath) : {
|
|
406
|
-
};
|
|
407
|
-
let resolvedConfig = (0, _resolveConfig).default(config);
|
|
408
|
-
if (args['--purge']) {
|
|
409
|
-
_log.default.warn('purge-flag-deprecated', [
|
|
410
|
-
'The `--purge` flag has been deprecated.',
|
|
411
|
-
'Please use `--content` instead.',
|
|
412
|
-
]);
|
|
413
|
-
if (!args['--content']) {
|
|
414
|
-
args['--content'] = args['--purge'];
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
if (args['--content']) {
|
|
418
|
-
resolvedConfig.content.files = args['--content'].split(/(?<!{[^}]+),/);
|
|
419
|
-
}
|
|
420
|
-
return resolvedConfig;
|
|
421
|
-
}
|
|
422
|
-
function extractFileGlobs(config) {
|
|
423
|
-
return config.content.files.filter((file)=>{
|
|
424
|
-
// Strings in this case are files / globs. If it is something else,
|
|
425
|
-
// like an object it's probably a raw content object. But this object
|
|
426
|
-
// is not watchable, so let's remove it.
|
|
427
|
-
return typeof file === 'string';
|
|
428
|
-
}).map((glob)=>(0, _normalizePath).default(glob)
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
function extractRawContent(config) {
|
|
432
|
-
return config.content.files.filter((file)=>{
|
|
433
|
-
return typeof file === 'object' && file !== null;
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
function getChangedContent(config) {
|
|
437
|
-
let changedContent = [];
|
|
438
|
-
// Resolve globs from the content config
|
|
439
|
-
let globs = extractFileGlobs(config);
|
|
440
|
-
let files = _fastGlob.default.sync(globs);
|
|
441
|
-
for (let file of files){
|
|
442
|
-
changedContent.push({
|
|
443
|
-
content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
|
|
444
|
-
extension: _path.default.extname(file).slice(1)
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
// Resolve raw content in the tailwind config
|
|
448
|
-
for (let { raw: content , extension ='html' } of extractRawContent(config)){
|
|
449
|
-
changedContent.push({
|
|
450
|
-
content,
|
|
451
|
-
extension
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
return changedContent;
|
|
455
|
-
}
|
|
456
|
-
async function buildOnce() {
|
|
457
|
-
let config = resolveConfig();
|
|
458
|
-
let changedContent = getChangedContent(config);
|
|
459
|
-
let tailwindPlugin = ()=>{
|
|
460
|
-
return {
|
|
461
|
-
postcssPlugin: 'tailwindcss',
|
|
462
|
-
Once (root, { result }) {
|
|
463
|
-
(0, _processTailwindFeatures).default(({ createContext })=>{
|
|
464
|
-
return ()=>{
|
|
465
|
-
return createContext(config, changedContent);
|
|
466
|
-
};
|
|
467
|
-
})(root, result);
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
};
|
|
471
|
-
tailwindPlugin.postcss = true;
|
|
472
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
|
|
473
|
-
[],
|
|
474
|
-
[]
|
|
475
|
-
];
|
|
476
|
-
let plugins = [
|
|
477
|
-
...beforePlugins,
|
|
478
|
-
tailwindPlugin,
|
|
479
|
-
!args['--minify'] && formatNodes,
|
|
480
|
-
...afterPlugins,
|
|
481
|
-
!args['--no-autoprefixer'] && (()=>{
|
|
482
|
-
// Try to load a local `autoprefixer` version first
|
|
483
|
-
try {
|
|
484
|
-
return require('autoprefixer');
|
|
485
|
-
} catch {
|
|
486
|
-
}
|
|
487
|
-
return (0, _indexJs).lazyAutoprefixer();
|
|
488
|
-
})(),
|
|
489
|
-
args['--minify'] && (()=>{
|
|
490
|
-
let options = {
|
|
491
|
-
preset: [
|
|
492
|
-
'default',
|
|
493
|
-
{
|
|
494
|
-
cssDeclarationSorter: false
|
|
495
|
-
}
|
|
496
|
-
]
|
|
497
|
-
};
|
|
498
|
-
// Try to load a local `cssnano` version first
|
|
499
|
-
try {
|
|
500
|
-
return require('cssnano');
|
|
501
|
-
} catch {
|
|
502
|
-
}
|
|
503
|
-
return (0, _indexJs).lazyCssnano()(options);
|
|
504
|
-
})(),
|
|
505
|
-
].filter(Boolean);
|
|
506
|
-
let processor = (0, _indexJs).postcss(plugins);
|
|
507
|
-
function processCSS(css) {
|
|
508
|
-
let start = process.hrtime.bigint();
|
|
509
|
-
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
510
|
-
recursive: true
|
|
511
|
-
}) : null
|
|
512
|
-
).then(()=>processor.process(css, {
|
|
513
|
-
from: input,
|
|
514
|
-
to: output
|
|
515
|
-
})
|
|
516
|
-
).then((result)=>{
|
|
517
|
-
if (!output) {
|
|
518
|
-
return process.stdout.write(result.css);
|
|
519
|
-
}
|
|
520
|
-
return Promise.all([
|
|
521
|
-
outputFile(output, result.css),
|
|
522
|
-
result.map && outputFile(output + '.map', result.map.toString()),
|
|
523
|
-
].filter(Boolean));
|
|
524
|
-
}).then(()=>{
|
|
525
|
-
let end = process.hrtime.bigint();
|
|
526
|
-
console.error();
|
|
527
|
-
console.error('Done in', (end - start) / BigInt(1000000) + 'ms.');
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
let css1 = await (()=>{
|
|
531
|
-
// Piping in data, let's drain the stdin
|
|
532
|
-
if (input === '-') {
|
|
533
|
-
return drainStdin();
|
|
534
|
-
}
|
|
535
|
-
// Input file has been provided
|
|
536
|
-
if (input) {
|
|
537
|
-
return _fs.default.readFileSync(_path.default.resolve(input), 'utf8');
|
|
538
|
-
}
|
|
539
|
-
// No input file provided, fallback to default atrules
|
|
540
|
-
return '@tailwind base; @tailwind components; @tailwind utilities';
|
|
541
|
-
})();
|
|
542
|
-
return processCSS(css1);
|
|
543
|
-
}
|
|
544
|
-
let context = null;
|
|
545
|
-
async function startWatcher() {
|
|
546
|
-
let changedContent = [];
|
|
547
|
-
let configDependencies = [];
|
|
548
|
-
let contextDependencies = new Set();
|
|
549
|
-
let watcher = null;
|
|
550
|
-
function refreshConfig() {
|
|
551
|
-
env.DEBUG && console.time('Module dependencies');
|
|
552
|
-
for (let file1 of configDependencies){
|
|
553
|
-
delete require.cache[require.resolve(file1)];
|
|
554
|
-
}
|
|
555
|
-
if (configPath) {
|
|
556
|
-
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file
|
|
557
|
-
);
|
|
558
|
-
for (let dependency of configDependencies){
|
|
559
|
-
contextDependencies.add(dependency);
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
env.DEBUG && console.timeEnd('Module dependencies');
|
|
563
|
-
return resolveConfig();
|
|
564
|
-
}
|
|
565
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [
|
|
566
|
-
[],
|
|
567
|
-
[]
|
|
568
|
-
];
|
|
569
|
-
let plugins = [
|
|
570
|
-
...beforePlugins,
|
|
571
|
-
'__TAILWIND_PLUGIN_POSITION__',
|
|
572
|
-
!args['--minify'] && formatNodes,
|
|
573
|
-
...afterPlugins,
|
|
574
|
-
!args['--no-autoprefixer'] && (()=>{
|
|
575
|
-
// Try to load a local `autoprefixer` version first
|
|
576
|
-
try {
|
|
577
|
-
return require('autoprefixer');
|
|
578
|
-
} catch {
|
|
579
|
-
}
|
|
580
|
-
return (0, _indexJs).lazyAutoprefixer();
|
|
581
|
-
})(),
|
|
582
|
-
args['--minify'] && (()=>{
|
|
583
|
-
let options = {
|
|
584
|
-
preset: [
|
|
585
|
-
'default',
|
|
586
|
-
{
|
|
587
|
-
cssDeclarationSorter: false
|
|
588
|
-
}
|
|
589
|
-
]
|
|
590
|
-
};
|
|
591
|
-
// Try to load a local `cssnano` version first
|
|
592
|
-
try {
|
|
593
|
-
return require('cssnano');
|
|
594
|
-
} catch {
|
|
595
|
-
}
|
|
596
|
-
return (0, _indexJs).lazyCssnano()(options);
|
|
597
|
-
})(),
|
|
598
|
-
].filter(Boolean);
|
|
599
|
-
async function rebuild(config) {
|
|
600
|
-
env.DEBUG && console.time('Finished in');
|
|
601
|
-
let tailwindPlugin = ()=>{
|
|
602
|
-
return {
|
|
603
|
-
postcssPlugin: 'tailwindcss',
|
|
604
|
-
Once (root, { result }) {
|
|
605
|
-
env.DEBUG && console.time('Compiling CSS');
|
|
606
|
-
(0, _processTailwindFeatures).default(({ createContext })=>{
|
|
607
|
-
console.error();
|
|
608
|
-
console.error('Rebuilding...');
|
|
609
|
-
return ()=>{
|
|
610
|
-
if (context !== null) {
|
|
611
|
-
context.changedContent = changedContent.splice(0);
|
|
612
|
-
return context;
|
|
613
|
-
}
|
|
614
|
-
env.DEBUG && console.time('Creating context');
|
|
615
|
-
context = createContext(config, changedContent.splice(0));
|
|
616
|
-
env.DEBUG && console.timeEnd('Creating context');
|
|
617
|
-
return context;
|
|
618
|
-
};
|
|
619
|
-
})(root, result);
|
|
620
|
-
env.DEBUG && console.timeEnd('Compiling CSS');
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
};
|
|
624
|
-
tailwindPlugin.postcss = true;
|
|
625
|
-
let tailwindPluginIdx = plugins.indexOf('__TAILWIND_PLUGIN_POSITION__');
|
|
626
|
-
let copy = plugins.slice();
|
|
627
|
-
copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
|
|
628
|
-
let processor = (0, _indexJs).postcss(copy);
|
|
629
|
-
function processCSS(css) {
|
|
630
|
-
let start = process.hrtime.bigint();
|
|
631
|
-
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
632
|
-
recursive: true
|
|
633
|
-
}) : null
|
|
634
|
-
).then(()=>processor.process(css, {
|
|
635
|
-
from: input,
|
|
636
|
-
to: output
|
|
637
|
-
})
|
|
638
|
-
).then(async (result)=>{
|
|
639
|
-
for (let message of result.messages){
|
|
640
|
-
if (message.type === 'dependency') {
|
|
641
|
-
contextDependencies.add(message.file);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
watcher.add([
|
|
645
|
-
...contextDependencies
|
|
646
|
-
]);
|
|
647
|
-
if (!output) {
|
|
648
|
-
return process.stdout.write(result.css);
|
|
649
|
-
}
|
|
650
|
-
return Promise.all([
|
|
651
|
-
outputFile(output, result.css),
|
|
652
|
-
result.map && outputFile(output + '.map', result.map.toString()),
|
|
653
|
-
].filter(Boolean));
|
|
654
|
-
}).then(()=>{
|
|
655
|
-
let end = process.hrtime.bigint();
|
|
656
|
-
console.error('Done in', (end - start) / BigInt(1000000) + 'ms.');
|
|
657
|
-
}).catch((err)=>{
|
|
658
|
-
if (err.name === 'CssSyntaxError') {
|
|
659
|
-
console.error(err.toString());
|
|
660
|
-
} else {
|
|
661
|
-
console.error(err);
|
|
662
|
-
}
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
let css2 = await (()=>{
|
|
666
|
-
// Piping in data, let's drain the stdin
|
|
667
|
-
if (input === '-') {
|
|
668
|
-
return drainStdin();
|
|
669
|
-
}
|
|
670
|
-
// Input file has been provided
|
|
671
|
-
if (input) {
|
|
672
|
-
return _fs.default.readFileSync(_path.default.resolve(input), 'utf8');
|
|
673
|
-
}
|
|
674
|
-
// No input file provided, fallback to default atrules
|
|
675
|
-
return '@tailwind base; @tailwind components; @tailwind utilities';
|
|
676
|
-
})();
|
|
677
|
-
let result1 = await processCSS(css2);
|
|
678
|
-
env.DEBUG && console.timeEnd('Finished in');
|
|
679
|
-
return result1;
|
|
680
|
-
}
|
|
681
|
-
let config1 = refreshConfig(configPath);
|
|
682
|
-
if (input) {
|
|
683
|
-
contextDependencies.add(_path.default.resolve(input));
|
|
684
|
-
}
|
|
685
|
-
watcher = _chokidar.default.watch([
|
|
686
|
-
...contextDependencies,
|
|
687
|
-
...extractFileGlobs(config1)
|
|
688
|
-
], {
|
|
689
|
-
ignoreInitial: true,
|
|
690
|
-
awaitWriteFinish: process.platform === 'win32' ? {
|
|
691
|
-
stabilityThreshold: 50,
|
|
692
|
-
pollInterval: 10
|
|
693
|
-
} : false
|
|
694
|
-
});
|
|
695
|
-
let chain = Promise.resolve();
|
|
696
|
-
watcher.on('change', async (file)=>{
|
|
697
|
-
if (contextDependencies.has(file)) {
|
|
698
|
-
env.DEBUG && console.time('Resolve config');
|
|
699
|
-
context = null;
|
|
700
|
-
config1 = refreshConfig(configPath);
|
|
701
|
-
env.DEBUG && console.timeEnd('Resolve config');
|
|
702
|
-
env.DEBUG && console.time('Watch new files');
|
|
703
|
-
let globs = extractFileGlobs(config1);
|
|
704
|
-
watcher.add(configDependencies);
|
|
705
|
-
watcher.add(globs);
|
|
706
|
-
env.DEBUG && console.timeEnd('Watch new files');
|
|
707
|
-
chain = chain.then(async ()=>{
|
|
708
|
-
changedContent.push(...getChangedContent(config1));
|
|
709
|
-
await rebuild(config1);
|
|
710
|
-
});
|
|
711
|
-
} else {
|
|
712
|
-
chain = chain.then(async ()=>{
|
|
713
|
-
changedContent.push({
|
|
714
|
-
content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
|
|
715
|
-
extension: _path.default.extname(file).slice(1)
|
|
716
|
-
});
|
|
717
|
-
await rebuild(config1);
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
watcher.on('add', async (file)=>{
|
|
722
|
-
chain = chain.then(async ()=>{
|
|
723
|
-
changedContent.push({
|
|
724
|
-
content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
|
|
725
|
-
extension: _path.default.extname(file).slice(1)
|
|
726
|
-
});
|
|
727
|
-
await rebuild(config1);
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
|
-
chain = chain.then(()=>{
|
|
731
|
-
changedContent.push(...getChangedContent(config1));
|
|
732
|
-
return rebuild(config1);
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
|
-
if (shouldWatch) {
|
|
736
|
-
/* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.on('end', ()=>process.exit(0)
|
|
737
|
-
);
|
|
738
|
-
process.stdin.resume();
|
|
739
|
-
startWatcher();
|
|
740
|
-
} else {
|
|
741
|
-
buildOnce();
|
|
742
|
-
}
|
|
743
|
-
}
|
|
239
|
+
run(args, configs);
|