@webiny/build-tools 6.6.0-alpha.6 → 6.6.0-alpha.7
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.
|
@@ -31,6 +31,9 @@ export const createRsbuildConfig = ({ cwd }) => {
|
|
|
31
31
|
createInjectTailwindSourcePlugin(
|
|
32
32
|
path.join(paths.projectRootFolder, "extensions")
|
|
33
33
|
),
|
|
34
|
+
createExcludeNonCodeFromTailwindScanPlugin(
|
|
35
|
+
getTailwindBasePath(paths.projectRootFolder)
|
|
36
|
+
),
|
|
34
37
|
tailwindcss({
|
|
35
38
|
base: getTailwindBasePath(paths.projectRootFolder)
|
|
36
39
|
}),
|
|
@@ -131,6 +134,28 @@ const createInjectTailwindSourcePlugin = sourcePath => ({
|
|
|
131
134
|
}
|
|
132
135
|
});
|
|
133
136
|
|
|
137
|
+
/*
|
|
138
|
+
Keeps files that can't hold a class name the app uses out of Tailwind's scan of the Webiny
|
|
139
|
+
packages. Tailwind reads every file under `base` looking for class names, then registers each
|
|
140
|
+
one as a build dependency. In a project that's `node_modules/@webiny`, about 38,000 files, and
|
|
141
|
+
two thirds of them are type declarations, source maps, icons and docs. Skipping them cuts the
|
|
142
|
+
scan to about 14,000 files.
|
|
143
|
+
|
|
144
|
+
The generated CSS loses only classes that appeared in those files alone, such as the examples
|
|
145
|
+
in a bundled agent skill's Markdown or in a type declaration. Code that uses a class has it in a
|
|
146
|
+
`.js` file, which is still scanned, and the project's own extensions are scanned separately.
|
|
147
|
+
*/
|
|
148
|
+
const NON_CODE_FILES = ["**/*.d.ts", "**/*.map", "**/*.svg", "**/*.md", "**/*.mdx"];
|
|
149
|
+
|
|
150
|
+
const createExcludeNonCodeFromTailwindScanPlugin = basePath => ({
|
|
151
|
+
postcssPlugin: "exclude-non-code-from-tailwind-scan",
|
|
152
|
+
Once(root) {
|
|
153
|
+
for (const pattern of NON_CODE_FILES) {
|
|
154
|
+
root.prepend(`@source not "${path.join(basePath, pattern)}";`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
134
159
|
/*
|
|
135
160
|
Removes any leftover `@source` at-rule from the output. Tailwind v4 strips the
|
|
136
161
|
directive from files it processes, but `@tailwindcss/postcss` only processes
|