-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
mode.js
32 lines (25 loc) · 840 Bytes
/
mode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require('fs');
const mode = process.env.NODE_ENV || 'dev';
const preHTML = `<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org" lang="en">
<th:block th:fragment="import()">`
const postHTML = ` </th:block>
</html>`;
const productionImport = `
<link
rel="stylesheet"
th:href="@{/assets/dist/main.css?v={version}(version=\${theme.spec.version})}"
/>
<script
th:src="@{/assets/dist/main.js?v={version}(version=\${theme.spec.version})}"
type="module"
></script>
`
const developmentImport = `
<script
th:src="@{http://localhost:5173/themes/halo-theme-chirpy/assets/dist/main.js}"
type="module"
></script>
`
const outHTML = preHTML + (mode === 'prod' ? productionImport : developmentImport) + postHTML
fs.writeFileSync('templates/modules/import.html', outHTML)