@web/rollup-plugin-html 0.0.0-canary-20230316175616
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/README.md +5 -0
- package/dist/RollupPluginHTMLOptions.d.ts +68 -0
- package/dist/RollupPluginHTMLOptions.d.ts.map +1 -0
- package/dist/RollupPluginHTMLOptions.js +3 -0
- package/dist/RollupPluginHTMLOptions.js.map +1 -0
- package/dist/assets/utils.d.ts +7 -0
- package/dist/assets/utils.d.ts.map +1 -0
- package/dist/assets/utils.js +138 -0
- package/dist/assets/utils.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/input/InputData.d.ts +16 -0
- package/dist/input/InputData.d.ts.map +1 -0
- package/dist/input/InputData.js +3 -0
- package/dist/input/InputData.js.map +1 -0
- package/dist/input/addRollupInput.d.ts +4 -0
- package/dist/input/addRollupInput.d.ts.map +1 -0
- package/dist/input/addRollupInput.js +36 -0
- package/dist/input/addRollupInput.js.map +1 -0
- package/dist/input/extract/extractAssets.d.ts +11 -0
- package/dist/input/extract/extractAssets.d.ts.map +1 -0
- package/dist/input/extract/extractAssets.js +37 -0
- package/dist/input/extract/extractAssets.js.map +1 -0
- package/dist/input/extract/extractModules.d.ts +13 -0
- package/dist/input/extract/extractModules.d.ts.map +1 -0
- package/dist/input/extract/extractModules.js +68 -0
- package/dist/input/extract/extractModules.js.map +1 -0
- package/dist/input/extract/extractModulesAndAssets.d.ts +14 -0
- package/dist/input/extract/extractModulesAndAssets.d.ts.map +1 -0
- package/dist/input/extract/extractModulesAndAssets.js +30 -0
- package/dist/input/extract/extractModulesAndAssets.js.map +1 -0
- package/dist/input/getInputData.d.ts +13 -0
- package/dist/input/getInputData.d.ts.map +1 -0
- package/dist/input/getInputData.js +94 -0
- package/dist/input/getInputData.js.map +1 -0
- package/dist/input/normalizeInputOptions.d.ts +4 -0
- package/dist/input/normalizeInputOptions.d.ts.map +1 -0
- package/dist/input/normalizeInputOptions.js +38 -0
- package/dist/input/normalizeInputOptions.js.map +1 -0
- package/dist/output/createHTMLOutput.d.ts +33 -0
- package/dist/output/createHTMLOutput.d.ts.map +1 -0
- package/dist/output/createHTMLOutput.js +39 -0
- package/dist/output/createHTMLOutput.js.map +1 -0
- package/dist/output/emitAssets.d.ts +12 -0
- package/dist/output/emitAssets.d.ts.map +1 -0
- package/dist/output/emitAssets.js +69 -0
- package/dist/output/emitAssets.js.map +1 -0
- package/dist/output/getEntrypointBundles.d.ts +18 -0
- package/dist/output/getEntrypointBundles.d.ts.map +1 -0
- package/dist/output/getEntrypointBundles.js +59 -0
- package/dist/output/getEntrypointBundles.js.map +1 -0
- package/dist/output/getOutputHTML.d.ts +18 -0
- package/dist/output/getOutputHTML.d.ts.map +1 -0
- package/dist/output/getOutputHTML.js +91 -0
- package/dist/output/getOutputHTML.js.map +1 -0
- package/dist/output/hashInlineScripts.d.ts +3 -0
- package/dist/output/hashInlineScripts.d.ts.map +1 -0
- package/dist/output/hashInlineScripts.js +131 -0
- package/dist/output/hashInlineScripts.js.map +1 -0
- package/dist/output/injectAbsoluteBaseUrl.d.ts +3 -0
- package/dist/output/injectAbsoluteBaseUrl.d.ts.map +1 -0
- package/dist/output/injectAbsoluteBaseUrl.js +37 -0
- package/dist/output/injectAbsoluteBaseUrl.js.map +1 -0
- package/dist/output/injectBundles.d.ts +5 -0
- package/dist/output/injectBundles.d.ts.map +1 -0
- package/dist/output/injectBundles.js +36 -0
- package/dist/output/injectBundles.js.map +1 -0
- package/dist/output/injectServiceWorkerRegistration.d.ts +9 -0
- package/dist/output/injectServiceWorkerRegistration.d.ts.map +1 -0
- package/dist/output/injectServiceWorkerRegistration.js +37 -0
- package/dist/output/injectServiceWorkerRegistration.js.map +1 -0
- package/dist/output/injectedUpdatedAssetPaths.d.ts +14 -0
- package/dist/output/injectedUpdatedAssetPaths.d.ts.map +1 -0
- package/dist/output/injectedUpdatedAssetPaths.js +60 -0
- package/dist/output/injectedUpdatedAssetPaths.js.map +1 -0
- package/dist/output/utils.d.ts +2 -0
- package/dist/output/utils.d.ts.map +1 -0
- package/dist/output/utils.js +12 -0
- package/dist/output/utils.js.map +1 -0
- package/dist/rollupPluginHTML.d.ts +13 -0
- package/dist/rollupPluginHTML.d.ts.map +1 -0
- package/dist/rollupPluginHTML.js +183 -0
- package/dist/rollupPluginHTML.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -0
- package/index.mjs +6 -0
- package/package.json +55 -0
- package/src/RollupPluginHTMLOptions.ts +92 -0
- package/src/assets/utils.ts +145 -0
- package/src/index.ts +14 -0
- package/src/input/InputData.ts +16 -0
- package/src/input/addRollupInput.ts +55 -0
- package/src/input/extract/extractAssets.ts +53 -0
- package/src/input/extract/extractModules.ts +78 -0
- package/src/input/extract/extractModulesAndAssets.ts +34 -0
- package/src/input/getInputData.ts +120 -0
- package/src/input/normalizeInputOptions.ts +47 -0
- package/src/output/createHTMLOutput.ts +87 -0
- package/src/output/emitAssets.ts +80 -0
- package/src/output/getEntrypointBundles.ts +88 -0
- package/src/output/getOutputHTML.ts +115 -0
- package/src/output/hashInlineScripts.ts +153 -0
- package/src/output/injectAbsoluteBaseUrl.ts +41 -0
- package/src/output/injectBundles.ts +44 -0
- package/src/output/injectServiceWorkerRegistration.ts +48 -0
- package/src/output/injectedUpdatedAssetPaths.ts +89 -0
- package/src/output/utils.ts +5 -0
- package/src/rollupPluginHTML.ts +225 -0
- package/src/utils.ts +9 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Document } from 'parse5';
|
|
3
|
+
import {
|
|
4
|
+
findElement,
|
|
5
|
+
getTagName,
|
|
6
|
+
appendChild,
|
|
7
|
+
createScript,
|
|
8
|
+
setAttribute,
|
|
9
|
+
} from '@web/parse5-utils';
|
|
10
|
+
|
|
11
|
+
export interface injectServiceWorkerRegistrationArgs {
|
|
12
|
+
document: Document;
|
|
13
|
+
serviceWorkerPath: string;
|
|
14
|
+
outputDir: string;
|
|
15
|
+
htmlFileName: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function injectServiceWorkerRegistration(args: injectServiceWorkerRegistrationArgs) {
|
|
19
|
+
const { document, serviceWorkerPath, outputDir, htmlFileName } = args;
|
|
20
|
+
const body = findElement(document, e => getTagName(e) === 'body');
|
|
21
|
+
if (!body) {
|
|
22
|
+
throw new Error('Missing body in HTML document.');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let serviceWorkerUrl = path.relative(outputDir, serviceWorkerPath);
|
|
26
|
+
serviceWorkerUrl = path.relative(path.dirname(htmlFileName), serviceWorkerUrl);
|
|
27
|
+
serviceWorkerUrl = serviceWorkerUrl.split(path.sep).join('/');
|
|
28
|
+
|
|
29
|
+
const code = `
|
|
30
|
+
if ('serviceWorker' in navigator) {
|
|
31
|
+
window.addEventListener('load', function() {
|
|
32
|
+
navigator.serviceWorker
|
|
33
|
+
.register('${serviceWorkerUrl}')
|
|
34
|
+
.then(function() {
|
|
35
|
+
console.log('ServiceWorker registered from "${serviceWorkerUrl}".');
|
|
36
|
+
})
|
|
37
|
+
.catch(function(err) {
|
|
38
|
+
console.log('ServiceWorker registration failed: ', err);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const script = createScript({}, code);
|
|
45
|
+
setAttribute(script, 'inject-service-worker', '');
|
|
46
|
+
|
|
47
|
+
appendChild(body, script);
|
|
48
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { getAttribute, setAttribute } from '@web/parse5-utils';
|
|
2
|
+
import { Document } from 'parse5';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
findAssets,
|
|
7
|
+
getSourceAttribute,
|
|
8
|
+
getSourcePaths,
|
|
9
|
+
isHashedAsset,
|
|
10
|
+
resolveAssetFilePath,
|
|
11
|
+
} from '../assets/utils';
|
|
12
|
+
import { InputData } from '../input/InputData';
|
|
13
|
+
import { createError } from '../utils';
|
|
14
|
+
import { EmittedAssets } from './emitAssets';
|
|
15
|
+
import { toBrowserPath } from './utils';
|
|
16
|
+
|
|
17
|
+
export interface InjectUpdatedAssetPathsArgs {
|
|
18
|
+
document: Document;
|
|
19
|
+
input: InputData;
|
|
20
|
+
outputDir: string;
|
|
21
|
+
rootDir: string;
|
|
22
|
+
emittedAssets: EmittedAssets;
|
|
23
|
+
publicPath?: string;
|
|
24
|
+
absolutePathPrefix?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getSrcSetUrlWidthPairs(srcset: string) {
|
|
28
|
+
if (!srcset) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const srcsetParts = srcset.includes(',') ? srcset.split(',') : [srcset];
|
|
32
|
+
const urls = srcsetParts
|
|
33
|
+
.map(url => url.trim())
|
|
34
|
+
.map(url => (url.includes(' ') ? url.split(' ') : [url]));
|
|
35
|
+
return urls;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function injectedUpdatedAssetPaths(args: InjectUpdatedAssetPathsArgs) {
|
|
39
|
+
const {
|
|
40
|
+
document,
|
|
41
|
+
input,
|
|
42
|
+
outputDir,
|
|
43
|
+
rootDir,
|
|
44
|
+
emittedAssets,
|
|
45
|
+
publicPath = './',
|
|
46
|
+
absolutePathPrefix,
|
|
47
|
+
} = args;
|
|
48
|
+
const assetNodes = findAssets(document);
|
|
49
|
+
|
|
50
|
+
for (const node of assetNodes) {
|
|
51
|
+
const sourcePaths = getSourcePaths(node);
|
|
52
|
+
for (const sourcePath of sourcePaths) {
|
|
53
|
+
const htmlFilePath = input.filePath ? input.filePath : path.join(rootDir, input.name);
|
|
54
|
+
const htmlDir = path.dirname(htmlFilePath);
|
|
55
|
+
const filePath = resolveAssetFilePath(sourcePath, htmlDir, rootDir, absolutePathPrefix);
|
|
56
|
+
const assetPaths = isHashedAsset(node) ? emittedAssets.hashed : emittedAssets.static;
|
|
57
|
+
const relativeOutputPath = assetPaths.get(filePath);
|
|
58
|
+
|
|
59
|
+
if (!relativeOutputPath) {
|
|
60
|
+
throw createError(
|
|
61
|
+
`Something went wrong while bundling HTML file ${input.name}. Could not find ${filePath} in emitted rollup assets.`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const htmlOutputFilePath = path.join(outputDir, input.name);
|
|
65
|
+
const htmlOutputDir = path.dirname(htmlOutputFilePath);
|
|
66
|
+
const absoluteOutputPath = path.join(outputDir, relativeOutputPath);
|
|
67
|
+
const relativePathToHtmlFile = path.relative(htmlOutputDir, absoluteOutputPath);
|
|
68
|
+
|
|
69
|
+
const browserPath = path.posix.join(publicPath, toBrowserPath(relativePathToHtmlFile));
|
|
70
|
+
const key = getSourceAttribute(node);
|
|
71
|
+
|
|
72
|
+
let newAttributeValue = browserPath;
|
|
73
|
+
if (key === 'srcset') {
|
|
74
|
+
const srcset = getAttribute(node, key);
|
|
75
|
+
if (srcset) {
|
|
76
|
+
const urlWidthPairs = getSrcSetUrlWidthPairs(srcset);
|
|
77
|
+
for (const urlWidthPair of urlWidthPairs) {
|
|
78
|
+
if (urlWidthPair[0] === sourcePath) {
|
|
79
|
+
urlWidthPair[0] = browserPath;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
newAttributeValue = urlWidthPairs.map(urlWidthPair => urlWidthPair.join(' ')).join(', ');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setAttribute(node, key, newAttributeValue);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Plugin } from 'rollup';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import { addRollupInput } from './input/addRollupInput';
|
|
5
|
+
import { getInputData } from './input/getInputData';
|
|
6
|
+
import { InputData } from './input/InputData';
|
|
7
|
+
import { createHTMLOutput } from './output/createHTMLOutput';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
GeneratedBundle,
|
|
11
|
+
RollupPluginHTMLOptions,
|
|
12
|
+
ScriptModuleTag,
|
|
13
|
+
TransformHtmlFunction,
|
|
14
|
+
} from './RollupPluginHTMLOptions';
|
|
15
|
+
import { createError, NOOP_IMPORT } from './utils';
|
|
16
|
+
import { emitAssets } from './output/emitAssets';
|
|
17
|
+
|
|
18
|
+
export interface RollupPluginHtml extends Plugin {
|
|
19
|
+
api: {
|
|
20
|
+
getInputs(): InputData[];
|
|
21
|
+
addHtmlTransformer(transformHtmlFunction: TransformHtmlFunction): void;
|
|
22
|
+
disableDefaultInject(): void;
|
|
23
|
+
addOutput(name: string): Plugin;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function rollupPluginHTML(pluginOptions: RollupPluginHTMLOptions = {}): RollupPluginHtml {
|
|
28
|
+
const multiOutputNames: string[] = [];
|
|
29
|
+
let inputs: InputData[] = [];
|
|
30
|
+
let generatedBundles: GeneratedBundle[] = [];
|
|
31
|
+
let externalTransformHtmlFns: TransformHtmlFunction[] = [];
|
|
32
|
+
let defaultInjectDisabled = false;
|
|
33
|
+
let serviceWorkerPath = '';
|
|
34
|
+
let injectServiceWorker = false;
|
|
35
|
+
let absolutePathPrefix: string;
|
|
36
|
+
let strictCSPInlineScripts = false;
|
|
37
|
+
|
|
38
|
+
function reset() {
|
|
39
|
+
inputs = [];
|
|
40
|
+
generatedBundles = [];
|
|
41
|
+
externalTransformHtmlFns = [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
name: '@web/rollup-plugin-html',
|
|
46
|
+
|
|
47
|
+
options(inputOptions) {
|
|
48
|
+
reset();
|
|
49
|
+
|
|
50
|
+
inputs = getInputData(pluginOptions, inputOptions.input);
|
|
51
|
+
const moduleImports: ScriptModuleTag[] = [];
|
|
52
|
+
|
|
53
|
+
for (const input of inputs) {
|
|
54
|
+
moduleImports.push(...input.moduleImports);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (moduleImports.length === 0) {
|
|
58
|
+
// if there are only pages with pure HTML we need to make sure there is at
|
|
59
|
+
// least some input for rollup
|
|
60
|
+
moduleImports.push(NOOP_IMPORT);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (pluginOptions.serviceWorkerPath) {
|
|
64
|
+
serviceWorkerPath = pluginOptions.serviceWorkerPath;
|
|
65
|
+
}
|
|
66
|
+
if (pluginOptions.injectServiceWorker) {
|
|
67
|
+
injectServiceWorker = pluginOptions.injectServiceWorker;
|
|
68
|
+
}
|
|
69
|
+
if (pluginOptions.absolutePathPrefix) {
|
|
70
|
+
absolutePathPrefix = pluginOptions.absolutePathPrefix;
|
|
71
|
+
}
|
|
72
|
+
if (pluginOptions.strictCSPInlineScripts) {
|
|
73
|
+
strictCSPInlineScripts = pluginOptions.strictCSPInlineScripts;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (pluginOptions.input == null) {
|
|
77
|
+
// we are reading rollup input, so replace whatever was there
|
|
78
|
+
return { ...inputOptions, input: moduleImports.map(mod => mod.importPath) };
|
|
79
|
+
} else {
|
|
80
|
+
// we need to add modules to existing rollup input
|
|
81
|
+
return addRollupInput(inputOptions, moduleImports);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/** Watch input files when running in watch mode */
|
|
86
|
+
buildStart() {
|
|
87
|
+
// watch filesf
|
|
88
|
+
for (const input of inputs) {
|
|
89
|
+
if (input.filePath) {
|
|
90
|
+
this.addWatchFile(input.filePath);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const asset of input.assets) {
|
|
94
|
+
this.addWatchFile(asset.filePath);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/** Notifies rollup that we will be handling these modules */
|
|
100
|
+
resolveId(id) {
|
|
101
|
+
if (id === NOOP_IMPORT.importPath) {
|
|
102
|
+
return NOOP_IMPORT.importPath;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
for (const input of inputs) {
|
|
106
|
+
if (input.inlineModules.find(mod => mod.importPath === id)) {
|
|
107
|
+
return id;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
/** Provide code for modules we are handling */
|
|
113
|
+
load(id) {
|
|
114
|
+
if (id === NOOP_IMPORT.importPath) {
|
|
115
|
+
return 'export default "noop"';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
for (const input of inputs) {
|
|
119
|
+
const foundMod = input.inlineModules.find(mod => mod.importPath === id);
|
|
120
|
+
if (foundMod) {
|
|
121
|
+
return foundMod.code;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Emits output html file if we are doing a single output build.
|
|
128
|
+
* @param {OutputOptions} options
|
|
129
|
+
* @param {OutputBundle} bundle
|
|
130
|
+
*/
|
|
131
|
+
async generateBundle(options, bundle) {
|
|
132
|
+
if (multiOutputNames.length !== 0) {
|
|
133
|
+
// we are generating multiple build outputs, which is handled by child plugins
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!options.dir) {
|
|
138
|
+
throw createError('Rollup output options must have a dir option set to emit an HTML file.');
|
|
139
|
+
}
|
|
140
|
+
generatedBundles.push({ name: 'default', options, bundle });
|
|
141
|
+
|
|
142
|
+
const emittedAssets = await emitAssets.call(this, inputs, pluginOptions);
|
|
143
|
+
const outputs = await createHTMLOutput({
|
|
144
|
+
outputDir: path.resolve(options.dir),
|
|
145
|
+
inputs,
|
|
146
|
+
emittedAssets,
|
|
147
|
+
generatedBundles,
|
|
148
|
+
externalTransformHtmlFns,
|
|
149
|
+
pluginOptions,
|
|
150
|
+
defaultInjectDisabled,
|
|
151
|
+
serviceWorkerPath,
|
|
152
|
+
injectServiceWorker,
|
|
153
|
+
absolutePathPrefix,
|
|
154
|
+
strictCSPInlineScripts,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
for (const output of outputs) {
|
|
158
|
+
this.emitFile(output);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
api: {
|
|
163
|
+
getInputs() {
|
|
164
|
+
return inputs;
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
addHtmlTransformer(transformHtmlFunction: TransformHtmlFunction) {
|
|
168
|
+
externalTransformHtmlFns.push(transformHtmlFunction);
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
disableDefaultInject() {
|
|
172
|
+
defaultInjectDisabled = true;
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
addOutput(name: string) {
|
|
176
|
+
if (!name || multiOutputNames.includes(name)) {
|
|
177
|
+
throw createError('Each output must have a unique name');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
multiOutputNames.push(name);
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
name: `@web/rollup-plugin-html-multi-output-${multiOutputNames.length}`,
|
|
184
|
+
|
|
185
|
+
async generateBundle(options, bundle) {
|
|
186
|
+
if (!options.dir) {
|
|
187
|
+
throw createError(`Output ${name} must have a dir option set.`);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
generatedBundles.push({ name, options, bundle });
|
|
191
|
+
|
|
192
|
+
if (generatedBundles.length === multiOutputNames.length) {
|
|
193
|
+
// this is the last build, emit the HTML files
|
|
194
|
+
const outputDirs = new Set(generatedBundles.map(b => b.options.dir));
|
|
195
|
+
if (outputDirs.size !== 1) {
|
|
196
|
+
throw createError(
|
|
197
|
+
'Unable to emit HTML output. Multiple rollup build outputs have a different output directory set.',
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const emittedAssets = await emitAssets.call(this, inputs, pluginOptions);
|
|
202
|
+
const outputs = await createHTMLOutput({
|
|
203
|
+
outputDir: path.resolve(options.dir),
|
|
204
|
+
inputs,
|
|
205
|
+
emittedAssets,
|
|
206
|
+
generatedBundles,
|
|
207
|
+
externalTransformHtmlFns,
|
|
208
|
+
pluginOptions,
|
|
209
|
+
defaultInjectDisabled,
|
|
210
|
+
serviceWorkerPath,
|
|
211
|
+
injectServiceWorker,
|
|
212
|
+
absolutePathPrefix,
|
|
213
|
+
strictCSPInlineScripts,
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
for (const output of outputs) {
|
|
217
|
+
this.emitFile(output);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
} as Plugin;
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ScriptModuleTag } from './RollupPluginHTMLOptions';
|
|
2
|
+
|
|
3
|
+
const PLUGIN = '[@web/rollup-plugin-html]';
|
|
4
|
+
|
|
5
|
+
export const NOOP_IMPORT: ScriptModuleTag = { importPath: '@web/rollup-plugin-html-noop' };
|
|
6
|
+
|
|
7
|
+
export function createError(msg: string) {
|
|
8
|
+
return new Error(`${PLUGIN} ${msg}`);
|
|
9
|
+
}
|