Skip to content

Commit

Permalink
ADD type property to indicate the iframe.html was reachable && test i…
Browse files Browse the repository at this point in the history
…f it's reachable from node
  • Loading branch information
ndelangen committed Aug 17, 2020
1 parent 8915f3c commit fea1c6f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/core/src/server/manager/manager-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import fs from 'fs-extra';
import findUp from 'find-up';
import resolveFrom from 'resolve-from';
import fetch from 'node-fetch';

import { logger } from '@storybook/node-logger';

Expand Down Expand Up @@ -91,6 +92,17 @@ async function getManagerWebpackConfig(options, presets) {
}
if (autoRefs || definedRefs) {
entries.push(path.resolve(path.join(options.configDir, `generated-refs.js`)));

// verify the refs are publicly reachable, if they are not we'll require stories.json at runtime, otherwise the ref won't work
await Promise.all(
Object.entries(refs).map(async ([k, value]) => {
const { ok } = await fetch(`${value.url}/iframe.html`).catch((e) => ({
ok: false,
}));

refs[k] = { ...value, type: ok ? 'server-checked' : 'unknown' };
})

This comment has been minimized.

Copy link
@SAMMY1265

SAMMY1265 Aug 20, 2020

refs

This comment has been minimized.

Copy link
@ndelangen

ndelangen Aug 20, 2020

Author Member

?

);
}

return presets.apply('managerWebpack', {}, { ...options, babelOptions, entries, refs });
Expand Down

0 comments on commit fea1c6f

Please sign in to comment.