mod-build 4.0.0-beta.4 → 4.0.0-beta.4b
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/grab-shared-scripts.js +0 -3
- package/vite.config.js +19 -8
package/package.json
CHANGED
|
@@ -228,11 +228,8 @@ function getResource(task, fileNames, resourcePath = 'quote/resources') {
|
|
|
228
228
|
|
|
229
229
|
export default async function(config) {
|
|
230
230
|
const { isLocal } = defaultSettings;
|
|
231
|
-
const isQuotePage = config.siteData?.isQuotePage || config.isQuotePage;
|
|
232
231
|
const useAccessibleComponents = config.useAccessibleConfig;
|
|
233
|
-
const useRelativePathForResources = config.siteData?.useRelativePathForResources || config.useRelativePathForResources;
|
|
234
232
|
componentFolderPath = useAccessibleComponents === true ? 'accessible-components' : 'shared-components';
|
|
235
|
-
isQuotePageOrUseRelativePath = isQuotePage === true || useRelativePathForResources === true;
|
|
236
233
|
const isPathSubdirectory = config.siteData?.pathSubdirectory || config.pathSubdirectory;
|
|
237
234
|
pathSubdirectory = !isLocal && isPathSubdirectory ? isPathSubdirectory : '';
|
|
238
235
|
|
package/vite.config.js
CHANGED
|
@@ -6,6 +6,8 @@ import { defineConfig } from 'vite'
|
|
|
6
6
|
import { startModBuild } from './tasks/serve.js'
|
|
7
7
|
import { updateConfig } from './src/scripts/utils.js'
|
|
8
8
|
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
|
9
|
+
import { glob } from 'glob'
|
|
10
|
+
import fs from "node:fs";
|
|
9
11
|
|
|
10
12
|
export default defineConfig((config) => ({
|
|
11
13
|
build: {
|
|
@@ -66,14 +68,23 @@ export default defineConfig((config) => ({
|
|
|
66
68
|
},
|
|
67
69
|
{
|
|
68
70
|
name: 'replace-src-paths',
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
writeBundle: async () => {
|
|
72
|
+
const files = glob.sync(defaultSettings.distFolder + '/**/index.html');
|
|
73
|
+
console.log(files);
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
let html = await fs.promises.readFile(file, 'utf-8');
|
|
76
|
+
let updatedHtml = '';
|
|
77
|
+
|
|
78
|
+
if (config.pathSubdirectory && config.pathSubdirectory.length > 0) {
|
|
79
|
+
updatedHtml = html
|
|
80
|
+
.replace(/(src|data-load)="\/?src\//g, `$1="${config.pathSubdirectory}`)
|
|
81
|
+
.replace(/(src|data-load|href)="\/?assets\//g, `$1="${config.pathSubdirectory}assets/`)
|
|
82
|
+
.replace(/(src|data-load|href)="\/?resources\//g, `$1="${config.pathSubdirectory}resources/`)
|
|
83
|
+
} else {
|
|
84
|
+
updatedHtml = html.replace(/(src|data-load)="\/?src\//g, '$1="/');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
await fs.promises.writeFile(file, updatedHtml);
|
|
77
88
|
}
|
|
78
89
|
},
|
|
79
90
|
apply: 'build',
|