Skip to content

Commit

Permalink
Handle windows paths
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Apr 8, 2022
1 parent 15b1dad commit c0b6bdb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/builder-vite/codegen-iframe-script.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import path from 'path';
import { normalizePath } from 'vite';
import { virtualPreviewFile, virtualStoriesFile } from './virtual-file-names';

import type { ExtendedOptions } from './types';

// We need to convert from an absolute path, to a traditional node module import path,
// so that vite can correctly pre-bundle/optimize
function transformPath(absPath: string) {
const splits = absPath.split('node_modules/');
const splits = absPath.split(`node_modules${path.sep}`);
// Return everything after the final "node_modules/"
return splits[splits.length - 1];
const module = normalizePath(splits[splits.length - 1]);
return module;
}

export async function generateIframeScriptCode(options: ExtendedOptions) {
Expand Down

0 comments on commit c0b6bdb

Please sign in to comment.