Repository: storybook
Issue: Storybook broken when running from symlink directory on Windows
Labels: bug,needs triage

**Describe the bug**
When running `start-storybook` or `build-storybook` from **the symlink directory** on Windows (observed on Windows 10 and Windows 11) Storybook crashes because of the missing files:
- `preview.js-generated-config-entry.js`
- `generated-stories-entry.js`
- `storybook-init-framework-entry.js`

**To Reproduce**
**WARNING**: to be able to reproduce this issue all actions **must** be executed from the `symlink` directory on Windows. It can be created by running [`mklink` command](https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/).

***Steps to reproduce:***
_Prerequisite:_ all actions must be run from the symlink directory.

1.  Run `npx create-react-app storybook-symlink`
2. Run `cd storybook-symlink`
3. Run `npx sb init`
4. Running `yarn storybook` causes:
```bash
99% done plugins webpack-hot-middlewarewebpack built preview 10561e59fc80a0183a6e in 3770ms
ModuleBuildError: Module build failed (from ../../Users/rawf/projects/storybook-symlink/node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error: ENOENT: no such file or directory, open 'C:\Users\rawf\projects\storybook-symlink\.storybook\preview.js-generated-config-entry.js'
    at processResult (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:758:19)
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:860:5
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:399:11
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:221:19
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:830:24
    at Array.eval (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
    at runCallbacks (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:27:15)
    at ReadFileContext.<anonymous> (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:200:4)
    at ReadFileContext.callback (C:\Users\rawf\projects\storybook-symlink\node_modules\graceful-fs\graceful-fs.js:123:16)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:282:13)
ModuleBuildError: Module build failed (from ../../Users/rawf/projects/storybook-symlink/node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error: ENOENT: no such file or directory, open 'C:\Users\rawf\projects\storybook-symlink\generated-stories-entry.js'
    at processResult (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:758:19)
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:860:5
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:399:11
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:221:19
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:830:24
    at Array.eval (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
    at runCallbacks (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:27:15)
    at ReadFileContext.<anonymous> (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:200:4)
    at ReadFileContext.callback (C:\Users\rawf\projects\storybook-symlink\node_modules\graceful-fs\graceful-fs.js:123:16)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:282:13)
ModuleBuildError: Module build failed (from ../../Users/rawf/projects/storybook-symlink/node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js):
Error: ENOENT: no such file or directory, open 'C:\Users\rawf\projects\storybook-symlink\storybook-init-framework-entry.js'
    at processResult (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:758:19)
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:860:5
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:399:11
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\loader-runner\lib\LoaderRunner.js:221:19
    at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\NormalModule.js:830:24
    at Array.eval (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
    at runCallbacks (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:27:15)
    at ReadFileContext.<anonymous> (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:200:4)
    at ReadFileContext.callback (C:\Users\rawf\projects\storybook-symlink\node_modules\graceful-fs\graceful-fs.js:123:16)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:282:13)
```
5. Running `yarn build-storybook` causes:
```bash
ERR! => Failed to build the preview
ERR! Module build failed: Error: ENOENT: no such file or directory, open 'C:\Users\rawf\projects\storybook-symlink\.storybook\preview.js-generated-config-entry.js'
ERR! Module build failed: Error: ENOENT: no such file or directory, open 'C:\Users\rawf\projects\storybook-symlink\generated-stories-entry.js'
ERR! Module build failed: Error: ENOENT: no such file or directory, open 'C:\Users\rawf\projects\storybook-symlink\storybook-init-framework-entry.js'
ERR! Error: => Webpack failed, learn more with --debug-webpack
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:200:62
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\HookWebpackError.js:68:3
ERR!     at Hook.eval [as callAsync] (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\Hook.js:18:14)
ERR!     at Cache.shutdown (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Cache.js:150:23)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:1212:15
ERR!     at Hook.eval [as callAsync] (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\Hook.js:18:14)
ERR!     at Compiler.close (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:1205:23)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:199:20
ERR!     at finalCallback (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:441:32)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:458:13
ERR!     at Hook.eval [as callAsync] (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:23:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\Hook.js:18:14)
ERR!     at onCompiled (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:456:21)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:1183:17
ERR!  Error: => Webpack failed, learn more with --debug-webpack
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:200:62
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\HookWebpackError.js:68:3
ERR!     at Hook.eval [as callAsync] (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\Hook.js:18:14)
ERR!     at Cache.shutdown (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Cache.js:150:23)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:1212:15
ERR!     at Hook.eval [as callAsync] (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\Hook.js:18:14)
ERR!     at Compiler.close (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:1205:23)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:199:20
ERR!     at finalCallback (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:441:32)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:458:13
ERR!     at Hook.eval [as callAsync] (eval at create (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:23:1)
ERR!     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\rawf\projects\storybook-symlink\node_modules\tapable\lib\Hook.js:18:14)
ERR!     at onCompiled (C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:456:21)
ERR!     at C:\Users\rawf\projects\storybook-symlink\node_modules\webpack\lib\Compiler.js:1183:17
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

**System**
System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
  Binaries:
    Node: 14.17.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (98.0.1108.62)
  npmPackages:
    @storybook/addon-actions: ^6.4.19 => 6.4.19
    @storybook/addon-essentials: ^6.4.19 => 6.4.19
    @storybook/addon-interactions: ^6.4.19 => 6.4.19
    @storybook/addon-links: ^6.4.19 => 6.4.19
    @storybook/builder-webpack5: ^6.4.19 => 6.4.19
    @storybook/manager-webpack5: ^6.4.19 => 6.4.19
    @storybook/node-logger: ^6.4.19 => 6.4.19
    @storybook/preset-create-react-app: ^4.0.1 => 4.0.1
    @storybook/react: ^6.4.19 => 6.4.19
    @storybook/testing-library: 0.0.9 => 0.0.9


**Additional context**
I wasn't able to reproduce this issue using `npx sb@next repro` because it crashed when I ran it from a symlink directory using Windows `cmd`:
```bash
C:\projects>npx sb@next repro
╭──────────────────────────────────────────────────────────────────────────────╮
│                                                                              │
│   🤗 Welcome to sb repro! 🤗                                                 │
│                                                                              │
│   Create a new project to minimally reproduce Storybook issues.              │
│                                                                              │
│   1. select an environment that most closely matches your project setup.     │
│   2. select a location for the reproduction, outside of your project.        │
│                                                                              │
│   After the reproduction is ready, we'll guide you through the next steps.   │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
√ 🌈 Select the repro framework » react
√ 📝 Select the repro base template » cra
√ Enter the output directory ... storybook-symlink-repro
🏃 Running cra into C:\projects\storybook-symlink-repro

🏃 Starting for cra latest

🏗 Bootstrapping cra project (this might take a few minutes)
npm_config_user_agent=npm npx -p create-react-app@latest create-react-app storybook-symlink-repro && cd storybook-symlink-repro && echo "FAST_REFRESH=true" > .env && echo "SKIP_PREFLIGHT_CHECK=true" > .env
'npm_config_user_agent' is not recognized as an internal or external command,
operable program or batch file.
An error occurred while executing: `npm_config_user_agent=npm npx -p create-react-app@latest create-react-app storybook-symlink-repro && cd storybook-symlink-repro && echo "FAST_REFRESH=true" > .env && echo "SKIP_PREFLIGHT_CHECK=true" > .env`
🚨 Bootstrapping cra failed
🚨 Failed to create repro
Error: Error: command exited with code: 1:
    at repro (C:\Users\rawf\AppData\Roaming\npm-cache\_npx\13772\node_modules\sb\node_modules\@storybook\cli\dist\cjs\repro.js:172:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
```