I am trying to render EJS components using Storybook HTML. I have two components that I am testing, paragraph and title . They are located in `views/partials’ from my root directory.
My stories are located in root/stories/index.js .
Here is what the file looks like:
import { storiesOf } from '@storybook/html';
import '../style.css'
import ejs from 'ejs'
storiesOf('EJS Demo', module)
.add('Hello', () => ejs.renderFile('../views/partials/title'))
I’ve got ejs and @storybook/html installed via npm, and I believe I have all other necessary packages.
After running npm run storybook , I am encountering the following warning and error messages:
WARNING in ./node_modules/ejs/lib/ejs.js 903:4-22
require.extensions is not supported by webpack. Use a loader instead.
@ ./stories/index.js 4:0-22 39:49-52
@ ./.storybook/config.js
@ multi ./node_modules/@storybook/core/dist/server/config/polyfills.js ./node_modules/@storybook/core/dist/server/config/globals.js ./.storybook/config.js (webpack)-hot-middleware/client.js?reload=true
WARNING in ./node_modules/ejs/lib/ejs.js 904:2-20
require.extensions is not supported by webpack. Use a loader instead.
@ ./stories/index.js 4:0-22 39:49-52
@ ./.storybook/config.js
@ multi ./node_modules/@storybook/core/dist/server/config/polyfills.js ./node_modules/@storybook/core/dist/server/config/globals.js ./.storybook/config.js (webpack)-hot-middleware/client.js?reload=true
ERROR in ./node_modules/ejs/lib/ejs.js
Module not found: Error: Can't resolve 'fs' in '/Users/lhuddlesto/Documents/Tip Calculator/node_modules/ejs/lib'
@ ./node_modules/ejs/lib/ejs.js 47:9-22
@ ./stories/index.js
@ ./.storybook/config.js
@ multi ./node_modules/@storybook/core/dist/server/config/polyfills.js ./node_modules/@storybook/core/dist/server/config/globals.js ./.storybook/config.js (webpack)-hot-middleware/client.js?reload=true
Could anyone provide more information about what these cryptic error messages mean?
I am wondering how this EJS can be compiled to HTML that Storybook can read and display. Is renderFile not the correct method to be using? I looked at some of the documentation available at www.ejs.co, but it hasn’t been very helpful.