Skip to content

Commit

Permalink
fix: resolves build error due to no REDIS_URL defined for storybook env
Browse files Browse the repository at this point in the history
- adds STORYBOOK_IS_STORYBOOK env var to prevent REDIS usage in storybook
  • Loading branch information
mohitb35 committed Apr 11, 2024
1 parent 4895e73 commit f54228e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
env:
STORYBOOK_IS_STORYBOOK: true
5 changes: 5 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ module.exports = {
docs: {
autodocs: true,
},

env: (config) => ({
...config,
STORYBOOK_IS_STORYBOOK: true,
}),
};
4 changes: 2 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useTheme } from '../src/theme/themeContext';
* https://storybook.js.org/docs/react/writing-stories/decorators#global-decorators
*/

const globalStyles = lazy(() => import('../src/theme/theme'));
// const globalStyles = lazy(() => import('../src/theme/theme'));

export const decorators = [
(Story, context) => {
Expand All @@ -29,7 +29,7 @@ export const decorators = [

return (
<I18nextProvider i18n={i18n}>
<style>{globalStyles}</style>
{/* <style>{globalStyles}</style> */}
<div className={`${themeType}`}>
<MUIThemeProvider theme={materialTheme}>
<ThemeProvider theme={materialTheme}>
Expand Down
3 changes: 3 additions & 0 deletions src/theme/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const getGlobalStyles = async () => {
const fetchConfig = async () => {
try {
let tenantConfig;
if (process.env.STORYBOOK_IS_STORYBOOK) {
return null;
}
if (typeof window !== 'undefined') {
// Check if tenantConfig is stored in local storage
const storedConfig = localStorage.getItem('tenantConfig');
Expand Down

0 comments on commit f54228e

Please sign in to comment.