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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.8.2
2
+ * tailwind-to-style v2.8.3
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.8.2
2
+ * tailwind-to-style v2.8.3
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * tailwind-to-style v2.8.2
2
+ * tailwind-to-style v2.8.3
3
3
  * Convert tailwind classes to inline style
4
4
  *
5
5
  * @author Bigetion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-to-style",
3
- "version": "2.8.2",
3
+ "version": "2.8.3",
4
4
  "description": "Convert tailwind classes to inline style",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -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
  }
@@ -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
  }