Use storybook for electron app
See original GitHub issueversions:
"@storybook/addon-actions": "^3.1.8",
"@storybook/react": "^3.1.8",
I’m trying to use Storybook with an electron app. The components are vanilla JS, but some of them import modules from electron
In my app, I configure webpack to target: 'electron-renderer', and this works fine
However, in storybook, doing so results in the error below.
Has anyone configured storybook to work correctly with electron?
external "crypto"?ef49:1 Uncaught ReferenceError: require is not defined
at Object.REACT_STATICS.childContextTypes (external "crypto"?ef49:1)
at __webpack_require__ (bootstrap 25805c1…?42ca:661)
at fn (bootstrap 25805c1…?42ca:87)
at Object.byteToHex (rng.js?025f:4)
at __webpack_require__ (bootstrap 25805c1…?42ca:661)
at fn (bootstrap 25805c1…?42ca:87)
at Object.<anonymous> (v1.js?2980:1)
at __webpack_require__ (bootstrap 25805c1…?42ca:661)
at fn (bootstrap 25805c1…?42ca:87)
at Object.<anonymous> (preview.js?2318:26)
| REACT_STATICS.childContextTypes | @ | external "crypto"?ef49:1
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| fn | @ | bootstrap 25805c1…?42ca:87
| byteToHex | @ | rng.js?025f:4
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| fn | @ | bootstrap 25805c1…?42ca:87
| (anonymous) | @ | v1.js?2980:1
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| fn | @ | bootstrap 25805c1…?42ca:87
| (anonymous) | @ | preview.js?2318:26
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| fn | @ | bootstrap 25805c1…?42ca:87
| canDefineProperty | @ | index.js?7950:16
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| fn | @ | bootstrap 25805c1…?42ca:87
| (anonymous) | @ | register.js:1
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| fn | @ | bootstrap 25805c1…?42ca:87
| (anonymous) | @ | addons.js:3
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| fn | @ | bootstrap 25805c1…?42ca:87
| (anonymous) | @ | ReactPropTypesSecret.js:14
| __webpack_require__ | @ | bootstrap 25805c1…?42ca:661
| validateFormat | @ | bootstrap 25805c1…?42ca:707
| (anonymous) | @ | manager.bundle.js:711
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12
Top Results From Across the Web
Use storybook for electron app · Issue #1435 - GitHub
I'm trying to use Storybook with an electron app. The components are vanilla JS, but some of them import modules from electron.
Read more >Storybook for Electron | Voters - Canny
Electron apps are made out of a wrapper over a normal website. ... there is a possibility for people wanting to use storybook...
Read more >Learn Electron, Firebase and React-storybook - Egghead.io
Build a desktop application with Electron · Local App Development with the Firebase Emulator Suite · Add React Storybook to a Project ·...
Read more >Electron vs React Storybook | What are the differences?
Electron - Build cross platform desktop apps with JavaScript, HTML, and CSS. React Storybook - Develop and design React components without an app....
Read more >Install Storybook
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK, got it working! 😜
requireis not available in the iframe but it is accessible in the parent document, usingtop.require(provided Electron is running with low security settings, which should be the case when it’s called using theelectronbinary, usingelectron http://localhost:9001). The trick is to overwrite default externals for webpack’selectron-renderertarget and any node-relatedrequirethat is called directly or indirectly by your components.Here is my
webpack.config.js:Has anyone been able to get this working with Electron? Would love to use Storybook for our Electron based project.