@cmmn/tools 1.6.19 → 1.6.25
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 +17 -5
- package/package.json +3 -2
package/bundle/rollup.config.js
CHANGED
|
@@ -6,8 +6,9 @@ import {string} from "rollup-plugin-string";
|
|
|
6
6
|
import serve from 'rollup-plugin-serve';
|
|
7
7
|
import builtins from 'rollup-plugin-node-builtins';
|
|
8
8
|
import livereload from 'rollup-plugin-livereload';
|
|
9
|
+
import copy from 'rollup-plugin-copy';
|
|
9
10
|
import fs from "fs";
|
|
10
|
-
import path from "path";
|
|
11
|
+
import path, {join} from "path";
|
|
11
12
|
import html from '@open-wc/rollup-plugin-html';
|
|
12
13
|
import json from '@rollup/plugin-json';
|
|
13
14
|
import alias from '@rollup/plugin-alias';
|
|
@@ -103,18 +104,21 @@ export class ConfigCreator {
|
|
|
103
104
|
template: (x) => {
|
|
104
105
|
let inject = Object.keys(x.bundle.bundle).map(key => {
|
|
105
106
|
if (key.endsWith('css'))
|
|
106
|
-
return `<link rel="stylesheet" href="/${key}" >`;
|
|
107
|
+
return `<link rel="stylesheet" href="${this.options.base ?? ''}/${key}" >`;
|
|
107
108
|
if (key.endsWith('js'))
|
|
108
|
-
return `<script type="module" defer src="/${key}"></script>`;
|
|
109
|
+
return `<script type="module" defer src="${this.options.base ?? ''}/${key}"></script>`;
|
|
109
110
|
}).join('\n');
|
|
110
111
|
if (!this.options.minify) {
|
|
111
112
|
const importMaps = Object.fromEntries(this.options.external
|
|
112
113
|
.map(key => key.replace('.*', '/'))
|
|
113
|
-
.map(key => [key, `/external/${this.options.alias[key] ?? key}`]));
|
|
114
|
+
.map(key => [key, `/external/${this.options.alias?.[key] ?? key}`]));
|
|
114
115
|
inject = `<script type="importmap" >${JSON.stringify({
|
|
115
116
|
imports: importMaps
|
|
116
117
|
})}</script>` + inject;
|
|
117
118
|
}
|
|
119
|
+
if (this.options.base){
|
|
120
|
+
inject = `<base href="${this.options.base}">` + inject;
|
|
121
|
+
}
|
|
118
122
|
const html = fs.readFileSync(path.join(this.root, this.options.html), 'utf8')
|
|
119
123
|
return html.replace('</head>', inject + '</head>');
|
|
120
124
|
}
|
|
@@ -202,6 +206,14 @@ export class ConfigCreator {
|
|
|
202
206
|
}))
|
|
203
207
|
}));
|
|
204
208
|
}
|
|
209
|
+
if (this.options.minify && this.options.mount){
|
|
210
|
+
const toCopy = Object.entries(this.options.mount).map(([to, from]) => {
|
|
211
|
+
return {src: from, dest: join(this.outDir, to)}
|
|
212
|
+
});
|
|
213
|
+
result.push(copy({
|
|
214
|
+
targets: toCopy
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
205
217
|
if (this.options.html || this.options.input.endsWith('.html')) {
|
|
206
218
|
result.push(this.html);
|
|
207
219
|
result.push(watcher([path.join(this.root, this.options.html)]))
|
|
@@ -268,7 +280,7 @@ export class ConfigCreator {
|
|
|
268
280
|
|
|
269
281
|
},
|
|
270
282
|
plugins: this.plugins,
|
|
271
|
-
treeshake: this.options.minify ? "
|
|
283
|
+
treeshake: this.options.minify ? "recommended" : "safest",
|
|
272
284
|
watch: {
|
|
273
285
|
buildDelay: 300,
|
|
274
286
|
clearScreen: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmmn/tools",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.25",
|
|
4
4
|
"description": "Compilation, bundling, code generator, testing.",
|
|
5
5
|
"main": "dist/rollup.config.js",
|
|
6
6
|
"type": "module",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"postcss-import": "14",
|
|
64
64
|
"postcss-modules": "*",
|
|
65
65
|
"rollup": "^2",
|
|
66
|
+
"rollup-plugin-copy": "3",
|
|
66
67
|
"rollup-plugin-livereload": "^2.0.5",
|
|
67
68
|
"rollup-plugin-node-builtins": "^2.1.2",
|
|
68
69
|
"rollup-plugin-node-globals": "^1.4.0",
|
|
@@ -81,5 +82,5 @@
|
|
|
81
82
|
},
|
|
82
83
|
"author": "",
|
|
83
84
|
"license": "ISC",
|
|
84
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "69a1243e5836906a3e6e89ed0bfd7543f5a380a8"
|
|
85
86
|
}
|