@cmmn/tools 1.7.9 → 1.7.11
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/bundle/rollup.config.js +6 -2
- package/package.json +2 -2
package/bundle/rollup.config.js
CHANGED
|
@@ -37,6 +37,7 @@ export class ConfigCreator {
|
|
|
37
37
|
* browser: boolean,
|
|
38
38
|
* dedupe: string[],
|
|
39
39
|
* target: string
|
|
40
|
+
* inject: string
|
|
40
41
|
* }}
|
|
41
42
|
*/
|
|
42
43
|
options;
|
|
@@ -103,7 +104,9 @@ export class ConfigCreator {
|
|
|
103
104
|
dir: this.outDir,
|
|
104
105
|
inject: false,
|
|
105
106
|
template: (x) => {
|
|
106
|
-
let inject =
|
|
107
|
+
let inject = (this.options.inject === "json") ? `<script>
|
|
108
|
+
globalThis.assets = ${JSON.stringify(Object.keys(x.bundle.bundle))};
|
|
109
|
+
</script>`: Object.keys(x.bundle.bundle).map(key => {
|
|
107
110
|
if (key.endsWith('css'))
|
|
108
111
|
return `<link rel="stylesheet" href="${this.options.base ?? ''}/${key}" >`;
|
|
109
112
|
if (key.endsWith('js'))
|
|
@@ -121,7 +124,8 @@ export class ConfigCreator {
|
|
|
121
124
|
inject = `<base href="${this.options.base}">` + inject;
|
|
122
125
|
}
|
|
123
126
|
const html = fs.readFileSync(path.join(this.root, this.options.html), 'utf8')
|
|
124
|
-
|
|
127
|
+
const interpolated = new Function(...Object.keys(this.options), `return \`${html}\`;`)(...Object.values(this.options));
|
|
128
|
+
return interpolated.replace('</head>', inject + '</head>');
|
|
125
129
|
}
|
|
126
130
|
});
|
|
127
131
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmmn/tools",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.11",
|
|
4
4
|
"description": "Compilation, bundling, code generator, testing.",
|
|
5
5
|
"main": "dist/rollup.config.js",
|
|
6
6
|
"type": "module",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
},
|
|
85
85
|
"author": "",
|
|
86
86
|
"license": "ISC",
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "1861dc80b2959b3a727f55174195cec7227b36fb"
|
|
88
88
|
}
|