@madgex/fert 7.0.0 → 7.0.1
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.
|
@@ -6,6 +6,7 @@ import { buildExternalAssets } from './build-external-assets.js';
|
|
|
6
6
|
import { log } from '../../utils/logging.js';
|
|
7
7
|
import { getAssetsPath } from '../../utils/get-assets-path.js';
|
|
8
8
|
import { buildTemplates } from './build-templates.js';
|
|
9
|
+
import { createAbsoluteManifest } from './create-absolute-manifest.js';
|
|
9
10
|
|
|
10
11
|
export async function bundleEntry(fertConfig, options = {}) {
|
|
11
12
|
let dynamicOptions = {};
|
|
@@ -37,6 +38,8 @@ export async function bundleEntry(fertConfig, options = {}) {
|
|
|
37
38
|
|
|
38
39
|
await vite.build(viteConfig);
|
|
39
40
|
|
|
41
|
+
createAbsoluteManifest(fertConfig.workingDir, assetsPath.href);
|
|
42
|
+
|
|
40
43
|
await buildTemplates(fertConfig, assetsPath.href);
|
|
41
44
|
|
|
42
45
|
await buildExternalAssets(fertConfig);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import { log } from '../../utils/logging.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Writes a new file based on Vite's `manifest.json`, but re-write the file paths to be absolute URLs pointing using `assetsPath`.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} workingDir
|
|
9
|
+
* @param {string} assetsPath absolute URL to prefix all file paths in manifest
|
|
10
|
+
*/
|
|
11
|
+
export function createAbsoluteManifest(workingDir, assetsPath) {
|
|
12
|
+
const distDir = path.resolve(workingDir, './dist/');
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(path.resolve(distDir, 'manifest.json'))) return;
|
|
15
|
+
|
|
16
|
+
const originalManifest = JSON.parse(fs.readFileSync(path.resolve(distDir, 'manifest.json'), 'utf8'));
|
|
17
|
+
|
|
18
|
+
for (const key in originalManifest) {
|
|
19
|
+
const entry = originalManifest[key];
|
|
20
|
+
|
|
21
|
+
// Update asset path to use asset-relay url
|
|
22
|
+
if (entry.file) {
|
|
23
|
+
entry.file = `${assetsPath}/${entry.file}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fs.writeFileSync(
|
|
28
|
+
path.resolve(distDir, 'manifest.absolute-urls.json'),
|
|
29
|
+
JSON.stringify(originalManifest, null, 2),
|
|
30
|
+
'utf8',
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
log.success('manifest.absolute-urls.json created');
|
|
34
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ASSET_RELAY_API } from '../../constants.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* fetch the Absolute URL `publicUrl` from asset-relay API, for current client & service
|
|
5
|
+
*
|
|
6
|
+
* @param {object} fertConfig
|
|
7
|
+
* @param {object} environment
|
|
8
|
+
* @returns {URL} Absoloute Public URL for assets
|
|
9
|
+
*/
|
|
3
10
|
export async function getAssetsPath(fertConfig, environment) {
|
|
4
11
|
const { clientPropertyId, serviceName, client, config } = fertConfig;
|
|
5
12
|
|
|
@@ -31,5 +38,7 @@ export async function getAssetsPath(fertConfig, environment) {
|
|
|
31
38
|
const data = await response.json();
|
|
32
39
|
const { publicUrl } = Array.isArray(data) ? data[0] : data;
|
|
33
40
|
|
|
34
|
-
|
|
41
|
+
// TODO: temporarily removing environment for production until all repos are on new version
|
|
42
|
+
// return new URL(`${publicUrl}/${environment}`);
|
|
43
|
+
return new URL(`${publicUrl}${environment === 'dev' ? '/dev' : ''}`);
|
|
35
44
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"public/fonts/mdgx-icons.eot": {
|
|
3
|
+
"file": "https://asset-relay.madgexjb.com/big-work-bag-6tORXNlh/assets/mdgx-icons-nszT880f.eot",
|
|
4
|
+
"src": "public/fonts/mdgx-icons.eot"
|
|
5
|
+
},
|
|
6
|
+
"public/fonts/mdgx-icons.svg": {
|
|
7
|
+
"file": "https://asset-relay.madgexjb.com/big-work-bag-6tORXNlh/assets/mdgx-icons-CLXOai0m.svg",
|
|
8
|
+
"src": "public/fonts/mdgx-icons.svg"
|
|
9
|
+
},
|
|
10
|
+
"public/fonts/mdgx-icons.ttf": {
|
|
11
|
+
"file": "https://asset-relay.madgexjb.com/big-work-bag-6tORXNlh/assets/mdgx-icons-dLFZ0BjQ.ttf",
|
|
12
|
+
"src": "public/fonts/mdgx-icons.ttf"
|
|
13
|
+
},
|
|
14
|
+
"public/fonts/mdgx-icons.woff": {
|
|
15
|
+
"file": "https://asset-relay.madgexjb.com/big-work-bag-6tORXNlh/assets/mdgx-icons-CmuOtNp9.woff",
|
|
16
|
+
"src": "public/fonts/mdgx-icons.woff"
|
|
17
|
+
},
|
|
18
|
+
"src/index.js": {
|
|
19
|
+
"file": "https://asset-relay.madgexjb.com/big-work-bag-6tORXNlh/assets/index-PBIhszZ7.js",
|
|
20
|
+
"name": "index",
|
|
21
|
+
"src": "src/index.js",
|
|
22
|
+
"isEntry": true,
|
|
23
|
+
"assets": [
|
|
24
|
+
"assets/mdgx-icons-nszT880f.eot",
|
|
25
|
+
"assets/mdgx-icons-CmuOtNp9.woff",
|
|
26
|
+
"assets/mdgx-icons-dLFZ0BjQ.ttf",
|
|
27
|
+
"assets/mdgx-icons-CLXOai0m.svg"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"style.css": {
|
|
31
|
+
"file": "https://asset-relay.madgexjb.com/big-work-bag-6tORXNlh/assets/style-BzoEQQhI.css",
|
|
32
|
+
"src": "style.css"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"public/fonts/mdgx-icons.eot": {
|
|
3
|
+
"file": "assets/mdgx-icons-nszT880f.eot",
|
|
4
|
+
"src": "public/fonts/mdgx-icons.eot"
|
|
5
|
+
},
|
|
6
|
+
"public/fonts/mdgx-icons.svg": {
|
|
7
|
+
"file": "assets/mdgx-icons-CLXOai0m.svg",
|
|
8
|
+
"src": "public/fonts/mdgx-icons.svg"
|
|
9
|
+
},
|
|
10
|
+
"public/fonts/mdgx-icons.ttf": {
|
|
11
|
+
"file": "assets/mdgx-icons-dLFZ0BjQ.ttf",
|
|
12
|
+
"src": "public/fonts/mdgx-icons.ttf"
|
|
13
|
+
},
|
|
14
|
+
"public/fonts/mdgx-icons.woff": {
|
|
15
|
+
"file": "assets/mdgx-icons-CmuOtNp9.woff",
|
|
16
|
+
"src": "public/fonts/mdgx-icons.woff"
|
|
17
|
+
},
|
|
18
|
+
"src/index.js": {
|
|
19
|
+
"file": "assets/index-PBIhszZ7.js",
|
|
20
|
+
"name": "index",
|
|
21
|
+
"src": "src/index.js",
|
|
22
|
+
"isEntry": true,
|
|
23
|
+
"assets": [
|
|
24
|
+
"assets/mdgx-icons-nszT880f.eot",
|
|
25
|
+
"assets/mdgx-icons-CmuOtNp9.woff",
|
|
26
|
+
"assets/mdgx-icons-dLFZ0BjQ.ttf",
|
|
27
|
+
"assets/mdgx-icons-CLXOai0m.svg"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"style.css": {
|
|
31
|
+
"file": "assets/style-BzoEQQhI.css",
|
|
32
|
+
"src": "style.css"
|
|
33
|
+
}
|
|
34
|
+
}
|