@rollup-extras/plugin-html 2.1.1 → 2.1.3
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/index.js +13 -5
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -101,7 +101,7 @@ export default function (options = {}) {
|
|
|
101
101
|
|
|
102
102
|
const processedFiles = new Set();
|
|
103
103
|
|
|
104
|
-
const instance = multiConfigPluginBase(useWriteBundle, pluginName, generateBundle, updateAssets);
|
|
104
|
+
const instance = multiConfigPluginBase(useWriteBundle, pluginName, generateBundle, updateAssets, resetAssets);
|
|
105
105
|
|
|
106
106
|
const baseRenderStart = (instance).renderStart;
|
|
107
107
|
const baseAddInstance = (instance.api.addInstance);
|
|
@@ -232,8 +232,7 @@ export default function (options = {}) {
|
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
processedFiles.clear();
|
|
235
|
+
resetAssets();
|
|
237
236
|
logger.finish('html file generated');
|
|
238
237
|
} catch (e) {
|
|
239
238
|
logger.finish('html generation failed', LogLevel.error, e);
|
|
@@ -241,11 +240,16 @@ export default function (options = {}) {
|
|
|
241
240
|
}
|
|
242
241
|
}
|
|
243
242
|
|
|
243
|
+
function resetAssets() {
|
|
244
|
+
assets = freshAssets();
|
|
245
|
+
processedFiles.clear();
|
|
246
|
+
}
|
|
247
|
+
|
|
244
248
|
async function getAssets(options, bundle) {
|
|
245
249
|
const dir = options.dir ?? '';
|
|
246
250
|
for (const fileName of Object.keys(bundle)) {
|
|
247
251
|
const relativeToRootAssetPath = join(dir, fileName);
|
|
248
|
-
const assetPath =
|
|
252
|
+
const assetPath = getAssetPath(relativeToRootAssetPath);
|
|
249
253
|
if (ignore(relativeToRootAssetPath) || processedFiles.has(relativeToRootAssetPath)) {
|
|
250
254
|
continue;
|
|
251
255
|
}
|
|
@@ -285,7 +289,7 @@ export default function (options = {}) {
|
|
|
285
289
|
if (modulepreload && options.format === 'es') {
|
|
286
290
|
const transitiveImports = collectTransitiveImports(bundle, fileName);
|
|
287
291
|
for (const importFileName of transitiveImports) {
|
|
288
|
-
const importAssetPath =
|
|
292
|
+
const importAssetPath = getAssetPath(join(dir, importFileName));
|
|
289
293
|
(assets.asset).push({
|
|
290
294
|
html: getModulePreloadElement(importAssetPath),
|
|
291
295
|
head: true,
|
|
@@ -298,6 +302,10 @@ export default function (options = {}) {
|
|
|
298
302
|
}
|
|
299
303
|
}
|
|
300
304
|
|
|
305
|
+
function getAssetPath(fileName) {
|
|
306
|
+
return relative(dirname(fileNameInInitialDir), fileName).replaceAll('\\', '/');
|
|
307
|
+
}
|
|
308
|
+
|
|
301
309
|
async function useAssetFactory(fileName, relativeToRootAssetPath, source, format) {
|
|
302
310
|
if (assetsFactory) {
|
|
303
311
|
try {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.1.
|
|
2
|
+
"version": "2.1.3",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "@rollup-extras/plugin-html",
|
|
5
5
|
"author": "Konstantin Shutkin",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@niceties/logger": "^2.1.0",
|
|
40
|
-
"@rollup-extras/utils": "^2.0.
|
|
40
|
+
"@rollup-extras/utils": "^2.0.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"rollup": "^4.0.0"
|