@web/dev-server-storybook
Version:
Dev server plugin for using storybook with es modules.
15 lines • 676 B
JavaScript
import path from 'path';
import pathIsInside from 'path-is-inside';
export function createError(msg) {
return new Error(`[@web/dev-server-storybook] ${msg}`);
}
export function createBrowserImport(rootDir, filePath) {
if (!pathIsInside(filePath, rootDir)) {
throw createError(`The file ${filePath} is not accessible by the browser because it is outside the root directory ${rootDir}. ` +
'Change the rootDir option to include this directory.');
}
const relativeFilePath = path.relative(rootDir, filePath);
const browserPath = relativeFilePath.split(path.sep).join('/');
return `./${browserPath}`;
}
//# sourceMappingURL=utils.js.map