shopify-accelerate-app 1.0.21 → 1.0.22
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/package.json +1 -1
- package/src/tailwind/tailwind-watch.ts +58 -54
package/package.json
CHANGED
|
@@ -53,70 +53,74 @@ export const runTailwindCSSWatcher = () => {
|
|
|
53
53
|
|
|
54
54
|
/*= =============== Tailwind Plugin Order ================ */
|
|
55
55
|
watch(path.join(config.extension_path, "assets"), { recursive: false }, async (evt, name) => {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
try {
|
|
57
|
+
if (!name.match(/tailwind_pre_sort.css$/) || !fs.existsSync(filePath)) return;
|
|
58
|
+
const file = fs.readFileSync(filePath, { encoding: "utf-8" });
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
const top = file
|
|
61
|
+
.split(/\n}/gi)
|
|
62
|
+
.filter((str) => !/\n@container \(/gi.test(str))
|
|
63
|
+
.join("\n}");
|
|
64
|
+
const bottom = `${file
|
|
65
|
+
.split(/\n}/gi)
|
|
66
|
+
.filter((str) => /\n@container \(/gi.test(str))
|
|
67
|
+
.join("\n}")}\n`;
|
|
68
|
+
const content = top + bottom;
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
const classesInOrder = [];
|
|
71
|
+
const omitCompoundClasses = [":not", ":where", ">", "*", ","];
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
content.split("\n").forEach((line) => {
|
|
74
|
+
if (!line.startsWith(".")) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
let writeOut = true;
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
omitCompoundClasses.forEach((classToOmit) => {
|
|
81
|
+
if (line.includes(classToOmit)) {
|
|
82
|
+
writeOut = false;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (writeOut) {
|
|
88
|
+
const finalClassName = line
|
|
89
|
+
.replace(/\./g, "")
|
|
90
|
+
.replace(/{/g, "")
|
|
91
|
+
.replace(/}/g, "")
|
|
92
|
+
.replace(/\\/g, "")
|
|
93
|
+
.trim();
|
|
94
|
+
if (finalClassName !== "") {
|
|
95
|
+
classesInOrder.push(`${finalClassName}`);
|
|
96
|
+
}
|
|
83
97
|
}
|
|
84
98
|
});
|
|
85
99
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
.replace(/{/g, "")
|
|
90
|
-
.replace(/}/g, "")
|
|
91
|
-
.replace(/\\/g, "")
|
|
92
|
-
.trim();
|
|
93
|
-
if (finalClassName !== "") {
|
|
94
|
-
classesInOrder.push(`${finalClassName}`);
|
|
95
|
-
}
|
|
100
|
+
writeCompareFile(path.join(config.extension_path, `assets/tailwind.css`), content);
|
|
101
|
+
if (process.env.SHOPIFY_ACCELERATE_THEME_OUTPUT_PATH) {
|
|
102
|
+
writeCompareFile(path.join(config.theme_output_path, `assets/tailwind.css`), content);
|
|
96
103
|
}
|
|
97
|
-
|
|
104
|
+
fs.unlinkSync(filePath);
|
|
98
105
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
writeCompareFile(
|
|
107
|
+
path.join(process.cwd(), ".tailwindorder"),
|
|
108
|
+
classesInOrder
|
|
109
|
+
.join("\n")
|
|
110
|
+
.replace(
|
|
111
|
+
new RegExp(
|
|
112
|
+
`${
|
|
113
|
+
process.env.SHOPIFY_ACCELERATE_TAILWIND_PREFIX
|
|
114
|
+
? `${process.env.SHOPIFY_ACCELERATE_TAILWIND_PREFIX}-`
|
|
115
|
+
: ""
|
|
116
|
+
}`,
|
|
117
|
+
"gi"
|
|
118
|
+
),
|
|
119
|
+
""
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.log(err);
|
|
102
124
|
}
|
|
103
|
-
fs.unlinkSync(filePath);
|
|
104
|
-
|
|
105
|
-
writeCompareFile(
|
|
106
|
-
path.join(process.cwd(), ".tailwindorder"),
|
|
107
|
-
classesInOrder
|
|
108
|
-
.join("\n")
|
|
109
|
-
.replace(
|
|
110
|
-
new RegExp(
|
|
111
|
-
`${
|
|
112
|
-
process.env.SHOPIFY_ACCELERATE_TAILWIND_PREFIX
|
|
113
|
-
? `${process.env.SHOPIFY_ACCELERATE_TAILWIND_PREFIX}-`
|
|
114
|
-
: ""
|
|
115
|
-
}`,
|
|
116
|
-
"gi"
|
|
117
|
-
),
|
|
118
|
-
""
|
|
119
|
-
)
|
|
120
|
-
);
|
|
121
125
|
});
|
|
122
126
|
};
|