-
Couldn't load subscription status.
- Fork 682
Added storybook to venia concept for scaffolding #2355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
devpatil7
merged 12 commits into
magento:develop
from
niklaswolf:2352-storybook-venia-concept
May 26, 2020
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8772071
Added storybook to venia concept for scaffolding
mothership-nik-wolf 91e5871
Merge branch 'develop' into 2352-storybook-venia-concept
ccd836a
Change to arrow function
mothership-nik-wolf 9c47fe9
Added storybook build
mothership-nik-wolf 443db9d
Merge remote-tracking branch 'origin/2352-storybook-venia-concept' in…
mothership-nik-wolf 7a4363c
Prettier Formatting Webpack config
mothership-nik-wolf d45608e
Merge branch 'develop' into 2352-storybook-venia-concept
devpatil7 674ce94
Merge branch 'develop' into 2352-storybook-venia-concept
9b36a97
- Fix Storybook for both venia-ui and scaffolded apps
tjwiebell d8dcc87
- Remove flag
tjwiebell ce3fb70
Merge branch 'develop' into 2352-storybook-venia-concept
devpatil7 7905bcb
Merge branch 'develop' into 2352-storybook-venia-concept
devpatil7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import React from 'react'; | ||
| import { configure, addDecorator } from '@storybook/react'; | ||
| import { Adapter } from '@magento/venia-drivers'; | ||
| import store from '../store'; | ||
| import '../index.css'; | ||
| import { PeregrineContextProvider } from '@magento/peregrine'; | ||
|
|
||
| const loadStories = () => { | ||
| // Load all stories from venia-ui | ||
| const veniaContext = require.context( | ||
| '../../node_modules/@magento/venia-ui/lib', | ||
| true, | ||
| /__stories__\/.+\.js$/ | ||
| ); | ||
| veniaContext.keys().forEach(veniaContext); | ||
|
|
||
| // Load all custom defined stories in src | ||
| const customContext = require.context('..', true, /__stories__\/.+\.js$/); | ||
| customContext.keys().forEach(customContext); | ||
| }; | ||
|
|
||
| const backendUrl = process.env.MAGENTO_BACKEND_URL; | ||
| const apiBase = new URL('/graphql', backendUrl).toString(); | ||
|
|
||
| addDecorator(storyFn => ( | ||
| <Adapter | ||
| apiBase={apiBase} | ||
| apollo={{ link: Adapter.apolloLink(apiBase) }} | ||
| store={store} | ||
| > | ||
| <PeregrineContextProvider>{storyFn()}</PeregrineContextProvider> | ||
| </Adapter> | ||
| )); | ||
|
|
||
| configure(loadStories, module); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| const path = require('path'); | ||
| const { | ||
| graphQL: { getUnionAndInterfaceTypes }, | ||
| Utilities: { loadEnvironment } | ||
| } = require('@magento/pwa-buildpack'); | ||
| const baseWebpackConfig = require('../../webpack.config'); | ||
| const { DefinePlugin, EnvironmentPlugin } = require('webpack'); | ||
|
|
||
| // Storybook 5.2.8 uses a different signature for webpack config than webpack | ||
| // defines in the docs. | ||
| // See https://storybook.js.org/docs/configurations/custom-webpack-config/#full-control-mode | ||
| module.exports = async ({ config: storybookBaseConfig, mode }) => { | ||
| const projectConfig = loadEnvironment( | ||
| // Load .env from root | ||
| path.resolve(__dirname, '../..') | ||
| ); | ||
|
|
||
| if (projectConfig.error) { | ||
| throw projectConfig.error; | ||
| } | ||
|
|
||
| const unionAndInterfaceTypes = await getUnionAndInterfaceTypes(); | ||
|
|
||
| const webpackConfig = await baseWebpackConfig(mode); | ||
|
|
||
| storybookBaseConfig.module = webpackConfig.module; | ||
| storybookBaseConfig.resolve = webpackConfig.resolve; | ||
|
|
||
| // Make sure to provide any plugins that UI code may depend on. | ||
| storybookBaseConfig.plugins = [ | ||
| ...storybookBaseConfig.plugins, | ||
| new DefinePlugin({ | ||
| UNION_AND_INTERFACE_TYPES: JSON.stringify(unionAndInterfaceTypes), | ||
| STORE_NAME: JSON.stringify('Storybook') | ||
| }), | ||
| new EnvironmentPlugin(projectConfig.env) | ||
| ]; | ||
|
|
||
| return storybookBaseConfig; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zetlen - I opted to move these scripts here from
package.jsonin venia-concept, since they weren't executable if attempting to run inside the mono (this assumesvenia-uiis innode_modules). This set off some snapshot failures and I didn't feel confident in which method is best. Couple clarifying questions:venia-concept?scriptsToInsertas intended?