@epublishing/grunt-epublishing 0.3.23 → 0.3.24
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/tasks/sass.js +18 -2
package/package.json
CHANGED
package/tasks/sass.js
CHANGED
|
@@ -37,6 +37,17 @@ module.exports = grunt => {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
// Ensure destination directory exists
|
|
41
|
+
const ensureDirectoryExists = async (filePath) => {
|
|
42
|
+
const dir = path.dirname(filePath);
|
|
43
|
+
try {
|
|
44
|
+
await fsPromises.access(dir);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// Directory doesn't exist, create it recursively
|
|
47
|
+
await fsPromises.mkdir(dir, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
40
51
|
grunt.registerMultiTask('sass', 'Compile Sass to CSS with performance optimizations', function () {
|
|
41
52
|
const done = this.async();
|
|
42
53
|
const startTime = Date.now();
|
|
@@ -44,7 +55,7 @@ module.exports = grunt => {
|
|
|
44
55
|
const options = this.options({
|
|
45
56
|
precision: 10,
|
|
46
57
|
cache: true,
|
|
47
|
-
parallel: true,
|
|
58
|
+
parallel: true, // Back to true for better performance
|
|
48
59
|
maxConcurrency: require('os').cpus().length
|
|
49
60
|
});
|
|
50
61
|
|
|
@@ -85,12 +96,16 @@ module.exports = grunt => {
|
|
|
85
96
|
|
|
86
97
|
const result = await util.promisify(sass.render)(sassOptions);
|
|
87
98
|
|
|
99
|
+
// Ensure destination directory exists
|
|
100
|
+
await ensureDirectoryExists(dest);
|
|
101
|
+
|
|
88
102
|
// Write CSS file
|
|
89
103
|
await fsPromises.writeFile(dest, result.css);
|
|
90
104
|
|
|
91
105
|
// Write source map if requested
|
|
92
106
|
if (taskOptions.sourceMap) {
|
|
93
107
|
const mapPath = taskOptions.sourceMap === true ? `${dest}.map` : taskOptions.sourceMap;
|
|
108
|
+
await ensureDirectoryExists(mapPath);
|
|
94
109
|
await fsPromises.writeFile(mapPath, result.map);
|
|
95
110
|
}
|
|
96
111
|
|
|
@@ -134,9 +149,10 @@ module.exports = grunt => {
|
|
|
134
149
|
(async () => {
|
|
135
150
|
try {
|
|
136
151
|
if (options.parallel) {
|
|
152
|
+
// Parallel processing - only use when files have no dependencies
|
|
137
153
|
await processWithConcurrency(compilationTasks, options.maxConcurrency);
|
|
138
154
|
} else {
|
|
139
|
-
// Sequential processing
|
|
155
|
+
// Sequential processing - safer for files with @import dependencies
|
|
140
156
|
for (const task of compilationTasks) {
|
|
141
157
|
await processFile(task);
|
|
142
158
|
}
|