tailwindcss 0.0.0-insiders.cb6e45a → 0.0.0-insiders.cb8af0c
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/README.md +7 -6
- package/lib/cli/build/deps.js +10 -18
- package/lib/cli/build/index.js +11 -34
- package/lib/cli/build/plugin.js +100 -240
- package/lib/cli/build/utils.js +18 -40
- package/lib/cli/build/watching.js +42 -90
- package/lib/cli/help/index.js +15 -58
- package/lib/cli/index.js +166 -13
- package/lib/cli/init/index.js +25 -32
- package/lib/cli-peer-dependencies.js +13 -15
- package/lib/cli.js +1 -227
- package/lib/corePluginList.js +7 -4
- package/lib/corePlugins.js +600 -795
- package/lib/css/preflight.css +4 -0
- package/lib/featureFlags.js +19 -32
- package/lib/index.js +1 -47
- package/lib/lib/cacheInvalidation.js +29 -75
- package/lib/lib/collapseAdjacentRules.js +22 -43
- package/lib/lib/collapseDuplicateDeclarations.js +24 -68
- package/lib/lib/content.js +44 -123
- package/lib/lib/defaultExtractor.js +94 -194
- package/lib/lib/detectNesting.js +12 -30
- package/lib/lib/evaluateTailwindFunctions.js +103 -188
- package/lib/lib/expandApplyAtRules.js +180 -460
- package/lib/lib/expandTailwindAtRules.js +95 -208
- package/lib/lib/findAtConfigPath.js +13 -30
- package/lib/lib/generateRules.js +348 -703
- package/lib/lib/getModuleDependencies.js +50 -40
- package/lib/lib/load-config.js +32 -0
- package/lib/lib/normalizeTailwindDirectives.js +26 -70
- package/lib/lib/offsets.js +72 -148
- package/lib/lib/partitionApplyAtRules.js +29 -51
- package/lib/lib/regex.js +22 -30
- package/lib/lib/remap-bitfield.js +12 -0
- package/lib/lib/resolveDefaultsAtRules.js +50 -116
- package/lib/lib/setupContextUtils.js +590 -1051
- package/lib/lib/setupTrackingContext.js +55 -123
- package/lib/lib/sharedState.js +21 -42
- package/lib/lib/substituteScreenAtRules.js +8 -16
- package/lib/oxide/cli/build/deps.js +66 -0
- package/lib/oxide/cli/build/index.js +21 -0
- package/lib/oxide/cli/build/plugin.js +193 -0
- package/lib/oxide/cli/build/utils.js +56 -0
- package/lib/oxide/cli/build/watching.js +63 -0
- package/lib/oxide/cli/help/index.js +28 -0
- package/lib/oxide/cli/index.js +153 -0
- package/lib/oxide/cli/init/index.js +31 -0
- package/lib/oxide/cli.js +4 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +34 -0
- package/lib/postcss-plugins/nesting/index.js +6 -10
- package/lib/postcss-plugins/nesting/plugin.js +18 -61
- package/lib/processTailwindFeatures.js +8 -37
- package/lib/public/colors.js +59 -44
- package/lib/public/create-plugin.js +5 -8
- package/lib/public/default-config.js +5 -9
- package/lib/public/default-theme.js +5 -9
- package/lib/public/load-config.js +8 -0
- package/lib/public/resolve-config.js +4 -6
- package/lib/util/applyImportantSelector.js +25 -0
- package/lib/util/bigSign.js +6 -7
- package/lib/util/buildMediaQuery.js +10 -17
- package/lib/util/cloneDeep.js +9 -17
- package/lib/util/cloneNodes.js +15 -28
- package/lib/util/color.js +45 -67
- package/lib/util/configurePlugins.js +9 -16
- package/lib/util/createPlugin.js +8 -15
- package/lib/util/createUtilityPlugin.js +15 -27
- package/lib/util/dataTypes.js +25 -119
- package/lib/util/defaults.js +9 -19
- package/lib/util/escapeClassName.js +6 -10
- package/lib/util/escapeCommas.js +6 -7
- package/lib/util/flattenColorPalette.js +6 -8
- package/lib/util/formatVariantSelector.js +83 -254
- package/lib/util/getAllConfigs.js +35 -42
- package/lib/util/hashConfig.js +6 -8
- package/lib/util/isKeyframeRule.js +6 -7
- package/lib/util/isPlainObject.js +8 -11
- package/lib/util/isSyntacticallyValidPropertyValue.js +43 -0
- package/lib/util/log.js +7 -14
- package/lib/util/nameClass.js +6 -21
- package/lib/util/negateValue.js +11 -27
- package/lib/util/normalizeConfig.js +71 -235
- package/lib/util/normalizeScreens.js +70 -137
- package/lib/util/parseAnimationValue.js +13 -61
- package/lib/util/parseBoxShadowValue.js +12 -57
- package/lib/util/parseDependency.js +13 -37
- package/lib/util/parseGlob.js +7 -22
- package/lib/util/parseObjectStyles.js +17 -26
- package/lib/util/pluginUtils.js +80 -187
- package/lib/util/prefixSelector.js +12 -15
- package/lib/util/pseudoElements.js +147 -0
- package/lib/util/removeAlphaVariables.js +8 -21
- package/lib/util/resolveConfig.js +104 -226
- package/lib/util/resolveConfigPath.js +25 -39
- package/lib/util/responsive.js +4 -6
- package/lib/util/splitAtTopLevelOnly.js +10 -38
- package/lib/util/tap.js +6 -8
- package/lib/util/toColorValue.js +6 -7
- package/lib/util/toPath.js +8 -26
- package/lib/util/transformThemeValue.js +12 -45
- package/lib/util/validateConfig.js +17 -14
- package/lib/util/validateFormalSyntax.js +5 -11
- package/lib/util/withAlphaVariable.js +28 -48
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/package.json +37 -26
- package/peers/index.js +771 -769
- package/resolveConfig.d.ts +11 -2
- package/scripts/swap-engines.js +40 -0
- package/src/cli/build/index.js +13 -9
- package/src/cli/build/plugin.js +80 -33
- package/src/cli/build/watching.js +108 -13
- package/src/cli/index.js +216 -3
- package/src/cli/init/index.js +37 -8
- package/src/cli.js +4 -220
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +220 -43
- package/src/css/preflight.css +4 -0
- package/src/featureFlags.js +6 -0
- package/src/index.js +1 -47
- package/src/lib/content.js +19 -16
- package/src/lib/defaultExtractor.js +9 -3
- package/src/lib/detectNesting.js +9 -1
- package/src/lib/expandApplyAtRules.js +43 -16
- package/src/lib/expandTailwindAtRules.js +35 -6
- package/src/lib/findAtConfigPath.js +4 -6
- package/src/lib/generateRules.js +126 -41
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/load-config.ts +31 -0
- package/src/lib/offsets.js +104 -1
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/setupContextUtils.js +127 -66
- package/src/lib/setupTrackingContext.js +35 -10
- package/src/lib/sharedState.js +15 -4
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +442 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +204 -0
- package/src/oxide/cli/init/index.ts +59 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -0
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/color.js +17 -2
- package/src/util/dataTypes.js +33 -4
- package/src/util/formatVariantSelector.js +162 -165
- package/src/util/getAllConfigs.js +2 -2
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/negateValue.js +1 -1
- package/src/util/normalizeConfig.js +20 -1
- package/src/util/pluginUtils.js +50 -39
- package/src/util/prefixSelector.js +28 -10
- package/src/util/pseudoElements.js +170 -0
- package/src/util/resolveConfig.js +3 -9
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +8 -1
- package/src/util/validateConfig.js +13 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +183 -163
- package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
- package/stubs/postcss.config.js +6 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +16 -9
- package/types/generated/colors.d.ts +22 -0
- package/types/generated/corePluginList.d.ts +1 -1
- package/types/generated/default-theme.d.ts +108 -79
- package/CHANGELOG.md +0 -2282
- package/lib/cli/shared.js +0 -12
- package/lib/constants.js +0 -44
- package/lib/util/isValidArbitraryValue.js +0 -72
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/cli/shared.js +0 -5
- package/src/constants.js +0 -17
- /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://tailwindcss.com
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<a href="https://tailwindcss.com" target="_blank">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg">
|
|
6
|
+
<img alt="Tailwind CSS" src="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg" width="350" height="70" style="max-width: 100%;">
|
|
7
|
+
</picture>
|
|
7
8
|
</a>
|
|
8
9
|
</p>
|
|
9
10
|
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
<p align="center">
|
|
16
|
-
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/workflow/status/tailwindlabs/tailwindcss/
|
|
17
|
+
<a href="https://github.com/tailwindlabs/tailwindcss/actions"><img src="https://img.shields.io/github/actions/workflow/status/tailwindlabs/tailwindcss/ci-stable.yml?branch=master" alt="Build Status"></a>
|
|
17
18
|
<a href="https://www.npmjs.com/package/tailwindcss"><img src="https://img.shields.io/npm/dt/tailwindcss.svg" alt="Total Downloads"></a>
|
|
18
19
|
<a href="https://github.com/tailwindcss/tailwindcss/releases"><img src="https://img.shields.io/npm/v/tailwindcss.svg" alt="Latest Release"></a>
|
|
19
20
|
<a href="https://github.com/tailwindcss/tailwindcss/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/tailwindcss.svg" alt="License"></a>
|
package/lib/cli/build/deps.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value:
|
|
5
|
-
})
|
|
6
|
-
function _export(target, all) {
|
|
3
|
+
value: !0
|
|
4
|
+
}), function(target, all) {
|
|
7
5
|
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
-
enumerable:
|
|
6
|
+
enumerable: !0,
|
|
9
7
|
get: all[name]
|
|
10
8
|
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
9
|
+
}(exports, {
|
|
13
10
|
loadPostcss: ()=>loadPostcss,
|
|
14
11
|
loadPostcssImport: ()=>loadPostcssImport,
|
|
15
12
|
loadCssNano: ()=>loadCssNano,
|
|
@@ -17,36 +14,31 @@ _export(exports, {
|
|
|
17
14
|
});
|
|
18
15
|
const _indexJs = require("../../../peers/index.js");
|
|
19
16
|
function loadPostcss() {
|
|
20
|
-
// Try to load a local `postcss` version first
|
|
21
17
|
try {
|
|
22
18
|
return require("postcss");
|
|
23
19
|
} catch {}
|
|
24
20
|
return (0, _indexJs.lazyPostcss)();
|
|
25
21
|
}
|
|
26
22
|
function loadPostcssImport() {
|
|
27
|
-
// Try to load a local `postcss-import` version first
|
|
28
23
|
try {
|
|
29
24
|
return require("postcss-import");
|
|
30
25
|
} catch {}
|
|
31
26
|
return (0, _indexJs.lazyPostcssImport)();
|
|
32
27
|
}
|
|
33
28
|
function loadCssNano() {
|
|
34
|
-
|
|
29
|
+
try {
|
|
30
|
+
return require("cssnano");
|
|
31
|
+
} catch {}
|
|
32
|
+
return (0, _indexJs.lazyCssnano)()({
|
|
35
33
|
preset: [
|
|
36
34
|
"default",
|
|
37
35
|
{
|
|
38
|
-
cssDeclarationSorter:
|
|
36
|
+
cssDeclarationSorter: !1
|
|
39
37
|
}
|
|
40
38
|
]
|
|
41
|
-
};
|
|
42
|
-
// Try to load a local `cssnano` version first
|
|
43
|
-
try {
|
|
44
|
-
return require("cssnano");
|
|
45
|
-
} catch {}
|
|
46
|
-
return (0, _indexJs.lazyCssnano)()(options);
|
|
39
|
+
});
|
|
47
40
|
}
|
|
48
41
|
function loadAutoprefixer() {
|
|
49
|
-
// Try to load a local `autoprefixer` version first
|
|
50
42
|
try {
|
|
51
43
|
return require("autoprefixer");
|
|
52
44
|
} catch {}
|
package/lib/cli/build/index.js
CHANGED
|
@@ -1,44 +1,21 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value:
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "build", {
|
|
5
|
+
enumerable: !0,
|
|
8
6
|
get: ()=>build
|
|
9
7
|
});
|
|
10
|
-
const _fs =
|
|
11
|
-
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
12
|
-
const _pluginJs = require("./plugin.js");
|
|
8
|
+
const _fs = _interopRequireDefault(require("fs")), _path = _interopRequireDefault(require("path")), _resolveConfigPathJs = require("../../util/resolveConfigPath.js"), _pluginJs = require("./plugin.js");
|
|
13
9
|
function _interopRequireDefault(obj) {
|
|
14
10
|
return obj && obj.__esModule ? obj : {
|
|
15
11
|
default: obj
|
|
16
12
|
};
|
|
17
13
|
}
|
|
18
|
-
async function build(args
|
|
19
|
-
let input = args["--input"];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
console.error(
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
if (input && input !== "-" && !_fs.default.existsSync(input = _path.default.resolve(input))) {
|
|
27
|
-
console.error(`Specified input file ${args["--input"]} does not exist.`);
|
|
28
|
-
process.exit(9);
|
|
29
|
-
}
|
|
30
|
-
if (args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"]))) {
|
|
31
|
-
console.error(`Specified config file ${args["--config"]} does not exist.`);
|
|
32
|
-
process.exit(9);
|
|
33
|
-
}
|
|
34
|
-
// TODO: Reference the @config path here if exists
|
|
35
|
-
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
|
|
36
|
-
let processor = await (0, _pluginJs.createProcessor)(args, configPath);
|
|
37
|
-
if (shouldWatch) {
|
|
38
|
-
/* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.on("end", ()=>process.exit(0));
|
|
39
|
-
process.stdin.resume();
|
|
40
|
-
await processor.watch();
|
|
41
|
-
} else {
|
|
42
|
-
await processor.build();
|
|
43
|
-
}
|
|
14
|
+
async function build(args) {
|
|
15
|
+
let input = args["--input"], shouldWatch = args["--watch"];
|
|
16
|
+
!input && args._[1] && (console.error("[deprecation] Running tailwindcss without -i, please provide an input file."), input = args["--input"] = args._[1]), input && "-" !== input && !_fs.default.existsSync(input = _path.default.resolve(input)) && (console.error(`Specified input file ${args["--input"]} does not exist.`), process.exit(9)), args["--config"] && !_fs.default.existsSync(args["--config"] = _path.default.resolve(args["--config"])) && (console.error(`Specified config file ${args["--config"]} does not exist.`), process.exit(9));
|
|
17
|
+
let processor = await (0, _pluginJs.createProcessor)(args, args["--config"] ? args["--config"] : (0, _resolveConfigPathJs.resolveDefaultConfigPath)());
|
|
18
|
+
shouldWatch ? ("always" !== args["--watch"] && process.stdin.on("end", ()=>process.exit(0)), process.stdin.resume(), await processor.watch()) : await processor.build().catch((e)=>{
|
|
19
|
+
console.error(e), process.exit(1);
|
|
20
|
+
});
|
|
44
21
|
}
|
package/lib/cli/build/plugin.js
CHANGED
|
@@ -1,120 +1,41 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value:
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
3
|
+
value: !0
|
|
4
|
+
}), Object.defineProperty(exports, "createProcessor", {
|
|
5
|
+
enumerable: !0,
|
|
8
6
|
get: ()=>createProcessor
|
|
9
7
|
});
|
|
10
|
-
const _path =
|
|
11
|
-
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
12
|
-
const _postcssLoadConfig = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config"));
|
|
13
|
-
const _lilconfig = require("lilconfig");
|
|
14
|
-
const _plugins = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/plugins" // Little bit scary, looking at private/internal API
|
|
15
|
-
));
|
|
16
|
-
const _options = /*#__PURE__*/ _interopRequireDefault(require("postcss-load-config/src/options" // Little bit scary, looking at private/internal API
|
|
17
|
-
));
|
|
18
|
-
const _processTailwindFeatures = /*#__PURE__*/ _interopRequireDefault(require("../../processTailwindFeatures"));
|
|
19
|
-
const _deps = require("./deps");
|
|
20
|
-
const _utils = require("./utils");
|
|
21
|
-
const _shared = require("../shared");
|
|
22
|
-
const _resolveConfigJs = /*#__PURE__*/ _interopRequireDefault(require("../../../resolveConfig.js"));
|
|
23
|
-
const _getModuleDependenciesJs = /*#__PURE__*/ _interopRequireDefault(require("../../lib/getModuleDependencies.js"));
|
|
24
|
-
const _contentJs = require("../../lib/content.js");
|
|
25
|
-
const _watchingJs = require("./watching.js");
|
|
26
|
-
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
27
|
-
const _findAtConfigPathJs = require("../../lib/findAtConfigPath.js");
|
|
28
|
-
const _log = /*#__PURE__*/ _interopRequireDefault(require("../../util/log"));
|
|
8
|
+
const _path = _interopRequireDefault(require("path")), _fs = _interopRequireDefault(require("fs")), _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config")), _lilconfig = require("lilconfig"), _plugins = _interopRequireDefault(require("postcss-load-config/src/plugins")), _options = _interopRequireDefault(require("postcss-load-config/src/options")), _processTailwindFeatures = _interopRequireDefault(require("../../processTailwindFeatures")), _deps = require("./deps"), _utils = require("./utils"), _sharedState = require("../../lib/sharedState"), _resolveConfigJs = _interopRequireDefault(require("../../../resolveConfig.js")), _contentJs = require("../../lib/content.js"), _watchingJs = require("./watching.js"), _fastGlob = _interopRequireDefault(require("fast-glob")), _findAtConfigPathJs = require("../../lib/findAtConfigPath.js"), _log = _interopRequireDefault(require("../../util/log")), _loadConfig = require("../../lib/load-config"), _getModuleDependencies = _interopRequireDefault(require("../../lib/getModuleDependencies"));
|
|
29
9
|
function _interopRequireDefault(obj) {
|
|
30
10
|
return obj && obj.__esModule ? obj : {
|
|
31
11
|
default: obj
|
|
32
12
|
};
|
|
33
13
|
}
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
* @param {string} [customPostCssPath ]
|
|
37
|
-
* @returns
|
|
38
|
-
*/ async function loadPostCssPlugins(customPostCssPath) {
|
|
14
|
+
async function loadPostCssPlugins(customPostCssPath) {
|
|
39
15
|
let config = customPostCssPath ? await (async ()=>{
|
|
40
|
-
let file = _path.default.resolve(customPostCssPath);
|
|
41
|
-
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
let { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
|
|
44
|
-
if (typeof config === "function") {
|
|
45
|
-
config = config();
|
|
46
|
-
} else {
|
|
47
|
-
config = Object.assign({}, config);
|
|
48
|
-
}
|
|
49
|
-
if (!config.plugins) {
|
|
50
|
-
config.plugins = [];
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
16
|
+
let file = _path.default.resolve(customPostCssPath), { config ={} } = await (0, _lilconfig.lilconfig)("postcss").load(file);
|
|
17
|
+
return (config = "function" == typeof config ? config() : Object.assign({}, config)).plugins || (config.plugins = []), {
|
|
53
18
|
file,
|
|
54
19
|
plugins: (0, _plugins.default)(config, file),
|
|
55
20
|
options: (0, _options.default)(config, file)
|
|
56
21
|
};
|
|
57
|
-
})() : await (0, _postcssLoadConfig.default)();
|
|
58
|
-
let configPlugins = config.plugins;
|
|
59
|
-
let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
|
|
60
|
-
if (typeof plugin === "function" && plugin.name === "tailwindcss") {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
if (typeof plugin === "object" && plugin !== null && plugin.postcssPlugin === "tailwindcss") {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
});
|
|
68
|
-
let beforePlugins = configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx);
|
|
69
|
-
let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
|
|
22
|
+
})() : await (0, _postcssLoadConfig.default)(), configPlugins = config.plugins, configPluginTailwindIdx = configPlugins.findIndex((plugin)=>"function" == typeof plugin && "tailwindcss" === plugin.name || "object" == typeof plugin && null !== plugin && "tailwindcss" === plugin.postcssPlugin);
|
|
70
23
|
return [
|
|
71
|
-
|
|
72
|
-
|
|
24
|
+
-1 === configPluginTailwindIdx ? [] : configPlugins.slice(0, configPluginTailwindIdx),
|
|
25
|
+
-1 === configPluginTailwindIdx ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1),
|
|
73
26
|
config.options
|
|
74
27
|
];
|
|
75
28
|
}
|
|
76
|
-
function loadBuiltinPostcssPlugins() {
|
|
77
|
-
let postcss = (0, _deps.loadPostcss)();
|
|
78
|
-
let IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ";
|
|
79
|
-
return [
|
|
80
|
-
[
|
|
81
|
-
(root)=>{
|
|
82
|
-
root.walkAtRules("import", (rule)=>{
|
|
83
|
-
if (rule.params.slice(1).startsWith("tailwindcss/")) {
|
|
84
|
-
rule.after(postcss.comment({
|
|
85
|
-
text: IMPORT_COMMENT + rule.params
|
|
86
|
-
}));
|
|
87
|
-
rule.remove();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
(0, _deps.loadPostcssImport)(),
|
|
92
|
-
(root)=>{
|
|
93
|
-
root.walkComments((rule)=>{
|
|
94
|
-
if (rule.text.startsWith(IMPORT_COMMENT)) {
|
|
95
|
-
rule.after(postcss.atRule({
|
|
96
|
-
name: "import",
|
|
97
|
-
params: rule.text.replace(IMPORT_COMMENT, "")
|
|
98
|
-
}));
|
|
99
|
-
rule.remove();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
[],
|
|
105
|
-
{}
|
|
106
|
-
];
|
|
107
|
-
}
|
|
108
29
|
let state = {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
30
|
+
context: null,
|
|
31
|
+
watcher: null,
|
|
32
|
+
changedContent: [],
|
|
33
|
+
configBag: null,
|
|
113
34
|
contextDependencies: new Set(),
|
|
114
|
-
|
|
35
|
+
contentPaths: [],
|
|
115
36
|
refreshContentPaths () {
|
|
116
|
-
var
|
|
117
|
-
this.contentPaths = (0, _contentJs.parseCandidateFiles)(this.context, (
|
|
37
|
+
var _this_context;
|
|
38
|
+
this.contentPaths = (0, _contentJs.parseCandidateFiles)(this.context, null === (_this_context = this.context) || void 0 === _this_context ? void 0 : _this_context.tailwindConfig);
|
|
118
39
|
},
|
|
119
40
|
get config () {
|
|
120
41
|
return this.context.tailwindConfig;
|
|
@@ -122,159 +43,105 @@ let state = {
|
|
|
122
43
|
get contentPatterns () {
|
|
123
44
|
return {
|
|
124
45
|
all: this.contentPaths.map((contentPath)=>contentPath.pattern),
|
|
125
|
-
dynamic: this.contentPaths.filter((contentPath)=>contentPath.glob
|
|
46
|
+
dynamic: this.contentPaths.filter((contentPath)=>void 0 !== contentPath.glob).map((contentPath)=>contentPath.pattern)
|
|
126
47
|
};
|
|
127
48
|
},
|
|
128
49
|
loadConfig (configPath, content) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
50
|
+
this.watcher && configPath && this.refreshConfigDependencies();
|
|
51
|
+
let config = (0, _loadConfig.loadConfig)(configPath), dependencies = (0, _getModuleDependencies.default)(configPath);
|
|
52
|
+
return this.configBag = {
|
|
53
|
+
config,
|
|
54
|
+
dependencies,
|
|
55
|
+
dispose () {
|
|
56
|
+
for (let file of dependencies)delete require.cache[require.resolve(file)];
|
|
57
|
+
}
|
|
58
|
+
}, this.configBag.config = (0, _resolveConfigJs.default)(this.configBag.config, {
|
|
135
59
|
content: {
|
|
136
60
|
files: []
|
|
137
61
|
}
|
|
138
|
-
});
|
|
139
|
-
// Override content files if `--content` has been passed explicitly
|
|
140
|
-
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
141
|
-
config.content.files = content;
|
|
142
|
-
}
|
|
143
|
-
return config;
|
|
62
|
+
}), (null == content ? void 0 : content.length) > 0 && (this.configBag.config.content.files = content), this.configBag.config;
|
|
144
63
|
},
|
|
145
|
-
refreshConfigDependencies (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
delete require.cache[require.resolve(file)];
|
|
149
|
-
}
|
|
150
|
-
if (configPath) {
|
|
151
|
-
let deps = (0, _getModuleDependenciesJs.default)(configPath).map(({ file })=>file);
|
|
152
|
-
for (let dependency of deps){
|
|
153
|
-
this.configDependencies.add(dependency);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
_shared.env.DEBUG && console.timeEnd("Module dependencies");
|
|
64
|
+
refreshConfigDependencies () {
|
|
65
|
+
var _this_configBag;
|
|
66
|
+
_sharedState.env.DEBUG && console.time("Module dependencies"), null === (_this_configBag = this.configBag) || void 0 === _this_configBag || _this_configBag.dispose(), _sharedState.env.DEBUG && console.timeEnd("Module dependencies");
|
|
157
67
|
},
|
|
158
68
|
readContentPaths () {
|
|
159
69
|
let content = [];
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
// Resolve raw content in the tailwind config
|
|
170
|
-
let rawContent = this.config.content.files.filter((file)=>{
|
|
171
|
-
return file !== null && typeof file === "object";
|
|
70
|
+
for (let file of _fastGlob.default.sync(this.contentPatterns.all))content.push({
|
|
71
|
+
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
72
|
+
extension: _path.default.extname(file).slice(1)
|
|
73
|
+
});
|
|
74
|
+
for (let { raw: htmlContent , extension ="html" } of this.config.content.files.filter((file)=>null !== file && "object" == typeof file))content.push({
|
|
75
|
+
content: htmlContent,
|
|
76
|
+
extension
|
|
172
77
|
});
|
|
173
|
-
for (let { raw: content1 , extension ="html" } of rawContent){
|
|
174
|
-
content1.push({
|
|
175
|
-
content: content1,
|
|
176
|
-
extension
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
78
|
return content;
|
|
180
79
|
},
|
|
181
80
|
getContext ({ createContext , cliConfigPath , root , result , content }) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var ref;
|
|
188
|
-
let configPath = (ref = (0, _findAtConfigPathJs.findAtConfigPath)(root, result)) !== null && ref !== void 0 ? ref : cliConfigPath;
|
|
189
|
-
_shared.env.DEBUG && console.timeEnd("Searching for config");
|
|
190
|
-
_shared.env.DEBUG && console.time("Loading config");
|
|
81
|
+
var _findAtConfigPath;
|
|
82
|
+
if (this.context) return this.context.changedContent = this.changedContent.splice(0), this.context;
|
|
83
|
+
_sharedState.env.DEBUG && console.time("Searching for config");
|
|
84
|
+
let configPath = null !== (_findAtConfigPath = (0, _findAtConfigPathJs.findAtConfigPath)(root, result)) && void 0 !== _findAtConfigPath ? _findAtConfigPath : cliConfigPath;
|
|
85
|
+
_sharedState.env.DEBUG && console.timeEnd("Searching for config"), _sharedState.env.DEBUG && console.time("Loading config");
|
|
191
86
|
let config = this.loadConfig(configPath, content);
|
|
192
|
-
|
|
193
|
-
_shared.env.DEBUG && console.time("Creating context");
|
|
194
|
-
this.context = createContext(config, []);
|
|
195
|
-
Object.assign(this.context, {
|
|
87
|
+
for (let file of (_sharedState.env.DEBUG && console.timeEnd("Loading config"), _sharedState.env.DEBUG && console.time("Creating context"), this.context = createContext(config, []), Object.assign(this.context, {
|
|
196
88
|
userConfigPath: configPath
|
|
197
|
-
});
|
|
198
|
-
_shared.env.DEBUG && console.timeEnd("Creating context");
|
|
199
|
-
_shared.env.DEBUG && console.time("Resolving content paths");
|
|
200
|
-
this.refreshContentPaths();
|
|
201
|
-
_shared.env.DEBUG && console.timeEnd("Resolving content paths");
|
|
202
|
-
if (this.watcher) {
|
|
203
|
-
_shared.env.DEBUG && console.time("Watch new files");
|
|
204
|
-
this.watcher.refreshWatchedFiles();
|
|
205
|
-
_shared.env.DEBUG && console.timeEnd("Watch new files");
|
|
206
|
-
}
|
|
207
|
-
_shared.env.DEBUG && console.time("Reading content files");
|
|
208
|
-
for (let file of this.readContentPaths()){
|
|
209
|
-
this.context.changedContent.push(file);
|
|
210
|
-
}
|
|
211
|
-
_shared.env.DEBUG && console.timeEnd("Reading content files");
|
|
89
|
+
}), _sharedState.env.DEBUG && console.timeEnd("Creating context"), _sharedState.env.DEBUG && console.time("Resolving content paths"), this.refreshContentPaths(), _sharedState.env.DEBUG && console.timeEnd("Resolving content paths"), this.watcher && (_sharedState.env.DEBUG && console.time("Watch new files"), this.watcher.refreshWatchedFiles(), _sharedState.env.DEBUG && console.timeEnd("Watch new files")), this.readContentPaths()))this.context.changedContent.push(file);
|
|
212
90
|
return this.context;
|
|
213
91
|
}
|
|
214
92
|
};
|
|
215
93
|
async function createProcessor(args, cliConfigPath) {
|
|
216
|
-
var
|
|
217
|
-
let postcss
|
|
218
|
-
let input = args["--input"]
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
94
|
+
var _args_content, _args_content_split;
|
|
95
|
+
let postcss, IMPORT_COMMENT;
|
|
96
|
+
let postcss1 = (0, _deps.loadPostcss)(), input = args["--input"], output = args["--output"], includePostCss = args["--postcss"], customPostCssPath = "string" == typeof args["--postcss"] ? args["--postcss"] : void 0, [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins(customPostCssPath) : (postcss = (0, _deps.loadPostcss)(), IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ", [
|
|
97
|
+
[
|
|
98
|
+
(root)=>{
|
|
99
|
+
root.walkAtRules("import", (rule)=>{
|
|
100
|
+
rule.params.slice(1).startsWith("tailwindcss/") && (rule.after(postcss.comment({
|
|
101
|
+
text: IMPORT_COMMENT + rule.params
|
|
102
|
+
})), rule.remove());
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
(0, _deps.loadPostcssImport)(),
|
|
106
|
+
(root)=>{
|
|
107
|
+
root.walkComments((rule)=>{
|
|
108
|
+
rule.text.startsWith(IMPORT_COMMENT) && (rule.after(postcss.atRule({
|
|
109
|
+
name: "import",
|
|
110
|
+
params: rule.text.replace(IMPORT_COMMENT, "")
|
|
111
|
+
})), rule.remove());
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
[],
|
|
116
|
+
{}
|
|
117
|
+
]);
|
|
118
|
+
args["--purge"] && (_log.default.warn("purge-flag-deprecated", [
|
|
119
|
+
"The `--purge` flag has been deprecated.",
|
|
120
|
+
"Please use `--content` instead."
|
|
121
|
+
]), args["--content"] || (args["--content"] = args["--purge"]));
|
|
122
|
+
let content = null !== (_args_content_split = null === (_args_content = args["--content"]) || void 0 === _args_content ? void 0 : _args_content.split(/(?<!{[^}]+),/)) && void 0 !== _args_content_split ? _args_content_split : [], tailwindPlugin = ()=>({
|
|
236
123
|
postcssPlugin: "tailwindcss",
|
|
237
124
|
Once (root, { result }) {
|
|
238
|
-
|
|
239
|
-
(0, _processTailwindFeatures.default)(({ createContext })=>{
|
|
240
|
-
console.error();
|
|
241
|
-
console.error("Rebuilding...");
|
|
242
|
-
return ()=>{
|
|
243
|
-
return state.getContext({
|
|
125
|
+
_sharedState.env.DEBUG && console.time("Compiling CSS"), (0, _processTailwindFeatures.default)(({ createContext })=>(console.error(), console.error("Rebuilding..."), ()=>state.getContext({
|
|
244
126
|
createContext,
|
|
245
127
|
cliConfigPath,
|
|
246
128
|
root,
|
|
247
129
|
result,
|
|
248
130
|
content
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
})(root, result);
|
|
252
|
-
_shared.env.DEBUG && console.timeEnd("Compiling CSS");
|
|
131
|
+
})))(root, result), _sharedState.env.DEBUG && console.timeEnd("Compiling CSS");
|
|
253
132
|
}
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
let plugins = [
|
|
133
|
+
});
|
|
134
|
+
tailwindPlugin.postcss = !0;
|
|
135
|
+
let processor = postcss1([
|
|
258
136
|
...beforePlugins,
|
|
259
137
|
tailwindPlugin,
|
|
260
138
|
!args["--minify"] && _utils.formatNodes,
|
|
261
139
|
...afterPlugins,
|
|
262
140
|
!args["--no-autoprefixer"] && (0, _deps.loadAutoprefixer)(),
|
|
263
141
|
args["--minify"] && (0, _deps.loadCssNano)()
|
|
264
|
-
].filter(Boolean);
|
|
265
|
-
/** @type {import('postcss').Processor} */ // @ts-ignore
|
|
266
|
-
let processor = postcss(plugins);
|
|
142
|
+
].filter(Boolean));
|
|
267
143
|
async function readInput() {
|
|
268
|
-
|
|
269
|
-
if (input === "-") {
|
|
270
|
-
return (0, _utils.drainStdin)();
|
|
271
|
-
}
|
|
272
|
-
// Input file has been provided
|
|
273
|
-
if (input) {
|
|
274
|
-
return _fs.default.promises.readFile(_path.default.resolve(input), "utf8");
|
|
275
|
-
}
|
|
276
|
-
// No input file provided, fallback to default atrules
|
|
277
|
-
return "@tailwind base; @tailwind components; @tailwind utilities";
|
|
144
|
+
return "-" === input ? (0, _utils.drainStdin)() : input ? _fs.default.promises.readFile(_path.default.resolve(input), "utf8") : "@tailwind base; @tailwind components; @tailwind utilities";
|
|
278
145
|
}
|
|
279
146
|
async function build() {
|
|
280
147
|
let start = process.hrtime.bigint();
|
|
@@ -283,53 +150,46 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
283
150
|
from: input,
|
|
284
151
|
to: output
|
|
285
152
|
})).then((result)=>{
|
|
153
|
+
if (!state.watcher) return result;
|
|
154
|
+
for (let message of (_sharedState.env.DEBUG && console.time("Recording PostCSS dependencies"), result.messages))"dependency" === message.type && state.contextDependencies.add(message.file);
|
|
155
|
+
return _sharedState.env.DEBUG && console.timeEnd("Recording PostCSS dependencies"), _sharedState.env.DEBUG && console.time("Watch new files"), state.watcher.refreshWatchedFiles(), _sharedState.env.DEBUG && console.timeEnd("Watch new files"), result;
|
|
156
|
+
}).then((result)=>{
|
|
286
157
|
if (!output) {
|
|
287
158
|
process.stdout.write(result.css);
|
|
288
159
|
return;
|
|
289
160
|
}
|
|
290
161
|
return Promise.all([
|
|
291
|
-
(0, _utils.outputFile)(
|
|
292
|
-
result.map && (0, _utils.outputFile)(
|
|
162
|
+
(0, _utils.outputFile)(result.opts.to, result.css),
|
|
163
|
+
result.map && (0, _utils.outputFile)(result.opts.to + ".map", result.map.toString())
|
|
293
164
|
]);
|
|
294
165
|
}).then(()=>{
|
|
295
166
|
let end = process.hrtime.bigint();
|
|
296
|
-
console.error();
|
|
297
|
-
|
|
167
|
+
console.error(), console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
168
|
+
}).then(()=>{}, (err)=>{
|
|
169
|
+
if (!state.watcher) return Promise.reject(err);
|
|
170
|
+
console.error(err);
|
|
298
171
|
});
|
|
299
172
|
}
|
|
300
|
-
|
|
301
|
-
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
|
302
|
-
*/ async function parseChanges(changes) {
|
|
173
|
+
async function parseChanges(changes) {
|
|
303
174
|
return Promise.all(changes.map(async (change)=>({
|
|
304
175
|
content: await change.content(),
|
|
305
176
|
extension: change.extension
|
|
306
177
|
})));
|
|
307
178
|
}
|
|
308
|
-
|
|
309
|
-
state.contextDependencies.add(_path.default.resolve(input));
|
|
310
|
-
}
|
|
311
|
-
return {
|
|
179
|
+
return void 0 !== input && "-" !== input && state.contextDependencies.add(_path.default.resolve(input)), {
|
|
312
180
|
build,
|
|
313
181
|
watch: async ()=>{
|
|
314
182
|
state.watcher = (0, _watchingJs.createWatcher)(args, {
|
|
315
183
|
state,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (needsNewContext) {
|
|
323
|
-
state.context = null;
|
|
324
|
-
} else {
|
|
325
|
-
for (let change of (await parseChanges(changes))){
|
|
326
|
-
state.changedContent.push(change);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
184
|
+
async rebuild (changes) {
|
|
185
|
+
if (changes.some((change)=>{
|
|
186
|
+
var _state_configBag;
|
|
187
|
+
return (null === (_state_configBag = state.configBag) || void 0 === _state_configBag ? void 0 : _state_configBag.dependencies.has(change.file)) || state.contextDependencies.has(change.file);
|
|
188
|
+
})) state.context = null;
|
|
189
|
+
else for (let change of (await parseChanges(changes)))state.changedContent.push(change);
|
|
329
190
|
return build();
|
|
330
191
|
}
|
|
331
|
-
});
|
|
332
|
-
await build();
|
|
192
|
+
}), await build();
|
|
333
193
|
}
|
|
334
194
|
};
|
|
335
195
|
}
|