tailwind-to-style 2.8.2 → 2.8.3
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/dist/index.browser.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
- package/plugins/vite-twsx.js +21 -0
- package/plugins/webpack-twsx.js +34 -0
package/dist/index.browser.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.esm.js
CHANGED
package/package.json
CHANGED
package/plugins/vite-twsx.js
CHANGED
|
@@ -20,6 +20,9 @@ function findTwsxFiles(dir, files = []) {
|
|
|
20
20
|
async function buildTwsx(inputDir, outputDir) {
|
|
21
21
|
try {
|
|
22
22
|
const twsxFiles = findTwsxFiles(inputDir);
|
|
23
|
+
const generatedCssFiles = [];
|
|
24
|
+
|
|
25
|
+
// Generate CSS from JS files
|
|
23
26
|
for (const filePath of twsxFiles) {
|
|
24
27
|
try {
|
|
25
28
|
const styleModule = await import(
|
|
@@ -30,6 +33,7 @@ async function buildTwsx(inputDir, outputDir) {
|
|
|
30
33
|
const fileName = path.basename(filePath).replace(/\.js$/, ".css");
|
|
31
34
|
const cssFilePath = path.join(outputDir, fileName);
|
|
32
35
|
fs.writeFileSync(cssFilePath, css);
|
|
36
|
+
generatedCssFiles.push(fileName);
|
|
33
37
|
} catch (err) {
|
|
34
38
|
console.error(
|
|
35
39
|
`[vite-twsx] Error importing or processing ${filePath}:`,
|
|
@@ -37,6 +41,23 @@ async function buildTwsx(inputDir, outputDir) {
|
|
|
37
41
|
);
|
|
38
42
|
}
|
|
39
43
|
}
|
|
44
|
+
|
|
45
|
+
// Clean up orphaned CSS files
|
|
46
|
+
if (fs.existsSync(outputDir)) {
|
|
47
|
+
const existingCssFiles = fs.readdirSync(outputDir)
|
|
48
|
+
.filter(file => file.startsWith('twsx.') && file.endsWith('.css'));
|
|
49
|
+
|
|
50
|
+
console.log(`[vite-twsx] Found ${existingCssFiles.length} existing CSS files:`, existingCssFiles);
|
|
51
|
+
console.log(`[vite-twsx] Generated ${generatedCssFiles.length} CSS files:`, generatedCssFiles);
|
|
52
|
+
|
|
53
|
+
for (const cssFile of existingCssFiles) {
|
|
54
|
+
if (!generatedCssFiles.includes(cssFile)) {
|
|
55
|
+
const cssFilePath = path.join(outputDir, cssFile);
|
|
56
|
+
fs.unlinkSync(cssFilePath);
|
|
57
|
+
console.log(`[vite-twsx] Removed orphaned CSS: ${cssFilePath}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
40
61
|
} catch (err) {
|
|
41
62
|
console.error("[vite-twsx] Error scanning for twsx files:", err);
|
|
42
63
|
}
|
package/plugins/webpack-twsx.js
CHANGED
|
@@ -20,6 +20,9 @@ function findTwsxFiles(dir, files = []) {
|
|
|
20
20
|
async function buildTwsx(inputDir, outputDir) {
|
|
21
21
|
try {
|
|
22
22
|
const twsxFiles = findTwsxFiles(inputDir);
|
|
23
|
+
const generatedCssFiles = [];
|
|
24
|
+
|
|
25
|
+
// Generate CSS from JS files
|
|
23
26
|
for (const filePath of twsxFiles) {
|
|
24
27
|
try {
|
|
25
28
|
const styleModule = await import(
|
|
@@ -30,6 +33,8 @@ async function buildTwsx(inputDir, outputDir) {
|
|
|
30
33
|
const fileName = path.basename(filePath).replace(/\.js$/, ".css");
|
|
31
34
|
const cssFilePath = path.join(outputDir, fileName);
|
|
32
35
|
fs.writeFileSync(cssFilePath, css);
|
|
36
|
+
generatedCssFiles.push(fileName);
|
|
37
|
+
console.log(`[webpack-twsx] CSS written to ${cssFilePath}`);
|
|
33
38
|
} catch (err) {
|
|
34
39
|
console.error(
|
|
35
40
|
`[webpack-twsx] Error importing or processing ${filePath}:`,
|
|
@@ -37,6 +42,35 @@ async function buildTwsx(inputDir, outputDir) {
|
|
|
37
42
|
);
|
|
38
43
|
}
|
|
39
44
|
}
|
|
45
|
+
|
|
46
|
+
// Clean up orphaned CSS files
|
|
47
|
+
if (fs.existsSync(outputDir)) {
|
|
48
|
+
const existingCssFiles = fs.readdirSync(outputDir).filter((file) => {
|
|
49
|
+
return file.startsWith("twsx.") && file.endsWith(".css");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
Array.isArray(existingCssFiles) &&
|
|
54
|
+
Array.isArray(generatedCssFiles)
|
|
55
|
+
) {
|
|
56
|
+
console.log(
|
|
57
|
+
`[webpack-twsx] Found ${existingCssFiles.length} existing CSS files:`,
|
|
58
|
+
existingCssFiles
|
|
59
|
+
);
|
|
60
|
+
console.log(
|
|
61
|
+
`[webpack-twsx] Generated ${generatedCssFiles.length} CSS files:`,
|
|
62
|
+
generatedCssFiles
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
for (const cssFile of existingCssFiles) {
|
|
66
|
+
if (!generatedCssFiles.includes(cssFile)) {
|
|
67
|
+
const cssFilePath = path.join(outputDir, cssFile);
|
|
68
|
+
fs.unlinkSync(cssFilePath);
|
|
69
|
+
console.log(`[webpack-twsx] Removed orphaned CSS: ${cssFilePath}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
40
74
|
} catch (err) {
|
|
41
75
|
console.error("[webpack-twsx] Error scanning for twsx files:", err);
|
|
42
76
|
}
|