summaryrefslogtreecommitdiff
path: root/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro/src/vite-plugin-build-html/add-rollup-input.ts')
-rw-r--r--packages/astro/src/vite-plugin-build-html/add-rollup-input.ts64
1 files changed, 32 insertions, 32 deletions
diff --git a/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts b/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts
index 4e84fbfa9..79feb3a7d 100644
--- a/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts
+++ b/packages/astro/src/vite-plugin-build-html/add-rollup-input.ts
@@ -1,43 +1,43 @@
import { InputOptions } from 'rollup';
function fromEntries<V>(entries: [string, V][]) {
- const obj: Record<string, V> = {};
- for (const [k, v] of entries) {
- obj[k] = v;
- }
- return obj;
+ const obj: Record<string, V> = {};
+ for (const [k, v] of entries) {
+ obj[k] = v;
+ }
+ return obj;
}
export function addRollupInput(inputOptions: InputOptions, newInputs: string[]): InputOptions {
- // Add input module ids to existing input option, whether it's a string, array or object
- // this way you can use multiple html plugins all adding their own inputs
- if (!inputOptions.input) {
- return { ...inputOptions, input: newInputs };
- }
+ // Add input module ids to existing input option, whether it's a string, array or object
+ // this way you can use multiple html plugins all adding their own inputs
+ if (!inputOptions.input) {
+ return { ...inputOptions, input: newInputs };
+ }
- if (typeof inputOptions.input === 'string') {
- return {
- ...inputOptions,
- input: [inputOptions.input, ...newInputs],
- };
- }
+ if (typeof inputOptions.input === 'string') {
+ return {
+ ...inputOptions,
+ input: [inputOptions.input, ...newInputs],
+ };
+ }
- if (Array.isArray(inputOptions.input)) {
- return {
- ...inputOptions,
- input: [...inputOptions.input, ...newInputs],
- };
- }
+ if (Array.isArray(inputOptions.input)) {
+ return {
+ ...inputOptions,
+ input: [...inputOptions.input, ...newInputs],
+ };
+ }
- if (typeof inputOptions.input === 'object') {
- return {
- ...inputOptions,
- input: {
- ...inputOptions.input,
- ...fromEntries(newInputs.map((i) => [i.split('/').slice(-1)[0].split('.')[0], i])),
- },
- };
- }
+ if (typeof inputOptions.input === 'object') {
+ return {
+ ...inputOptions,
+ input: {
+ ...inputOptions.input,
+ ...fromEntries(newInputs.map((i) => [i.split('/').slice(-1)[0].split('.')[0], i])),
+ },
+ };
+ }
- throw new Error(`Unknown rollup input type. Supported inputs are string, array and object.`);
+ throw new Error(`Unknown rollup input type. Supported inputs are string, array and object.`);
}