@pronto-tools-and-more/pronto 11.5.0 → 11.7.0
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pronto-tools-and-more/pronto",
|
3
|
-
"version": "11.
|
3
|
+
"version": "11.7.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "src/main.js",
|
6
6
|
"type": "module",
|
@@ -17,16 +17,16 @@
|
|
17
17
|
"@lvce-editor/ipc": "^11.7.0",
|
18
18
|
"@lvce-editor/json-rpc": "^5.3.0",
|
19
19
|
"@lvce-editor/verror": "^1.6.0",
|
20
|
-
"@pronto-tools-and-more/file-watcher": "11.
|
21
|
-
"@pronto-tools-and-more/files": "11.
|
22
|
-
"@pronto-tools-and-more/network-process": "11.
|
23
|
-
"@pronto-tools-and-more/sass-compiler": "11.
|
24
|
-
"@pronto-tools-and-more/components-renderer": "11.
|
25
|
-
"@pronto-tools-and-more/components": "11.
|
26
|
-
"@pronto-tools-and-more/schema-process": "11.
|
27
|
-
"@pronto-tools-and-more/diff-process": "11.
|
28
|
-
"@pronto-tools-and-more/type-checker": "11.
|
29
|
-
"@pronto-tools-and-more/custom-js-functions": "11.
|
20
|
+
"@pronto-tools-and-more/file-watcher": "11.7.0",
|
21
|
+
"@pronto-tools-and-more/files": "11.7.0",
|
22
|
+
"@pronto-tools-and-more/network-process": "11.7.0",
|
23
|
+
"@pronto-tools-and-more/sass-compiler": "11.7.0",
|
24
|
+
"@pronto-tools-and-more/components-renderer": "11.7.0",
|
25
|
+
"@pronto-tools-and-more/components": "11.7.0",
|
26
|
+
"@pronto-tools-and-more/schema-process": "11.7.0",
|
27
|
+
"@pronto-tools-and-more/diff-process": "11.7.0",
|
28
|
+
"@pronto-tools-and-more/type-checker": "11.7.0",
|
29
|
+
"@pronto-tools-and-more/custom-js-functions": "11.7.0",
|
30
30
|
"execa": "^9.5.2",
|
31
31
|
"express": "^4.21.2"
|
32
32
|
},
|
package/src/parts/App/App.js
CHANGED
@@ -14,6 +14,7 @@ export const create = ({
|
|
14
14
|
root,
|
15
15
|
appId,
|
16
16
|
baseUrl,
|
17
|
+
rootSassFile,
|
17
18
|
contentUrl,
|
18
19
|
platform,
|
19
20
|
managerBaseUrl,
|
@@ -88,7 +89,7 @@ export const create = ({
|
|
88
89
|
injectCustomJs,
|
89
90
|
})
|
90
91
|
);
|
91
|
-
app.use("*", HandleCss.handleCss(storeFrontPath));
|
92
|
+
app.use("*", HandleCss.handleCss(storeFrontPath, rootSassFile));
|
92
93
|
app.use(express.static(FilesPath.filesPath));
|
93
94
|
if (mode === "slim") {
|
94
95
|
app.use(
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { readdir, stat } from "fs/promises";
|
2
|
-
import { join } from "path";
|
2
|
+
import { dirname, join } from "path";
|
3
3
|
import * as Etag from "../Etag/Etag.js";
|
4
4
|
|
5
|
-
export const getCssEtag = async (storefrontPath) => {
|
5
|
+
export const getCssEtag = async (storefrontPath, rootSassFile) => {
|
6
6
|
try {
|
7
|
-
const scssPath =
|
7
|
+
const scssPath = dirname(rootSassFile);
|
8
8
|
const dirents = await readdir(scssPath, {
|
9
9
|
recursive: true,
|
10
10
|
});
|
@@ -21,7 +21,7 @@ export const getCssEtag = async (storefrontPath) => {
|
|
21
21
|
);
|
22
22
|
return Etag.fromStats(stats);
|
23
23
|
} catch (error) {
|
24
|
-
console.warn(`Failed to compute css etag ${error}`);
|
24
|
+
console.warn(`[server] Failed to compute css etag ${error}`);
|
25
25
|
return `css-${Math.random()}`;
|
26
26
|
}
|
27
27
|
};
|
@@ -6,35 +6,39 @@ import * as Config from "../Config/Config.js";
|
|
6
6
|
import * as GetCssEtag from "../GetCssEtag/GetCssEtag.js";
|
7
7
|
import * as UpdateCss from "../UpdateCss/UpdateCss.js";
|
8
8
|
|
9
|
-
export const handleCss =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
9
|
+
export const handleCss =
|
10
|
+
(storeFrontPath, rootSassFile) => async (req, res, next) => {
|
11
|
+
const pathName = req._parsedUrl.pathname;
|
12
|
+
if (!pathName.endsWith(".css")) {
|
13
|
+
return next();
|
14
|
+
}
|
15
|
+
res.setHeader("content-type", "text/css");
|
16
|
+
if (pathName === "/assets/custom.css") {
|
17
|
+
try {
|
18
|
+
const ifNoneMatch = req.headers["if-none-match"];
|
19
|
+
const cssEtag = await GetCssEtag.getCssEtag(
|
20
|
+
storeFrontPath,
|
21
|
+
rootSassFile
|
22
|
+
);
|
23
|
+
if (ifNoneMatch && ifNoneMatch === cssEtag) {
|
24
|
+
res.statusCode = 304;
|
25
|
+
res.end();
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
const result = await CompileSass.compileSass(Config.rootSassFile);
|
29
|
+
res.setHeader("Etag", cssEtag);
|
30
|
+
res.end(result.css);
|
31
|
+
} catch (error) {
|
32
|
+
console.warn(error);
|
33
|
+
res.end(`css error: ${error}`);
|
23
34
|
}
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
res.end(`css error: ${error}`);
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
const cssPath = join(storeFrontPath, pathName);
|
38
|
+
if (!existsSync(cssPath)) {
|
39
|
+
return next();
|
30
40
|
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
return next();
|
36
|
-
}
|
37
|
-
const cssContent = await readFile(cssPath, "utf8");
|
38
|
-
const newCss = UpdateCss.updateCss(cssContent);
|
39
|
-
res.end(newCss);
|
40
|
-
};
|
41
|
+
const cssContent = await readFile(cssPath, "utf8");
|
42
|
+
const newCss = UpdateCss.updateCss(cssContent);
|
43
|
+
res.end(newCss);
|
44
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
export const version = '11.
|
1
|
+
export const version = '11.7.0'
|