-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4836 from storybooks/react/cra-integration-fixes
React - use babel presets/plugins based on CRA.
- Loading branch information
Showing
23 changed files
with
597 additions
and
503 deletions.
There are no files selected for viewing
This file contains 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 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 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
3 changes: 2 additions & 1 deletion
3
...t/src/server/__tests__/cra-config.test.js → app/react/src/server/cra-config.test.js
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,36 @@ | ||
import { logger } from '@storybook/node-logger'; | ||
import { applyCRAWebpackConfig, isReactScriptsInstalled } from './cra-config'; | ||
|
||
export function webpackFinal(config) { | ||
if (!isReactScriptsInstalled()) { | ||
logger.info('=> Using base config because react-scripts is not installed.'); | ||
return config; | ||
} | ||
|
||
logger.info('=> Loading create-react-app config.'); | ||
|
||
return applyCRAWebpackConfig(config); | ||
} | ||
|
||
export function babelDefault(config) { | ||
if (!isReactScriptsInstalled()) { | ||
return config; | ||
} | ||
|
||
return { | ||
...config, | ||
presets: [require.resolve('babel-preset-react-app')], | ||
plugins: [ | ||
[ | ||
require.resolve('babel-plugin-named-asset-import'), | ||
{ | ||
loaderMap: { | ||
svg: { | ||
ReactComponent: '@svgr/webpack?-prettier,-svgo![path]', | ||
}, | ||
}, | ||
}, | ||
], | ||
], | ||
}; | ||
} |
This file contains 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 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 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 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,7 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
|
||
// eslint-disable-next-line import/extensions,import/no-unresolved | ||
import App from 'App'; | ||
|
||
storiesOf('App', module).add('full app', () => <App />); |
This file contains 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,5 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import LifecycleLogger from '../components/LifecycleLogger'; | ||
|
||
storiesOf('Lifecycle', module).add('logging', () => <LifecycleLogger />); |
29 changes: 29 additions & 0 deletions
29
examples/cra-kitchen-sink/src/stories/__snapshots__/App.stories.storyshot
This file contains 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,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots App full app 1`] = ` | ||
<div | ||
class="App" | ||
> | ||
<div | ||
class="App-header" | ||
> | ||
<img | ||
alt="logo" | ||
class="App-logo" | ||
src="logo.svg" | ||
/> | ||
<h2> | ||
Welcome to React | ||
</h2> | ||
</div> | ||
<p | ||
class="App-intro" | ||
> | ||
To get started, edit | ||
<code> | ||
src/App.js | ||
</code> | ||
and save to reload. | ||
</p> | ||
</div> | ||
`; |
7 changes: 7 additions & 0 deletions
7
examples/cra-kitchen-sink/src/stories/__snapshots__/Lifecycle.stories.storyshot
This file contains 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,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Lifecycle logging 1`] = ` | ||
<div> | ||
Lifecycle methods are logged to the console | ||
</div> | ||
`; |
13 changes: 13 additions & 0 deletions
13
examples/cra-kitchen-sink/src/stories/__snapshots__/cra-dynamic-import.stories.storyshot
This file contains 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,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots CRA Dynamic import 1`] = ` | ||
<div> | ||
Waiting for Dynamic Import | ||
</div> | ||
`; | ||
|
||
exports[`Storyshots CRA Svgr 1`] = ` | ||
<svg> | ||
logo.svg | ||
</svg> | ||
`; |
This file contains 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
18 changes: 18 additions & 0 deletions
18
examples/cra-kitchen-sink/src/stories/__snapshots__/long-description.stories.storyshot
This file contains 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,18 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Some really long story kind description with text 1`] = ` | ||
<div | ||
style="position:fixed;top:0;left:0;bottom:0;right:0;display:flex;align-items:center;overflow:auto" | ||
> | ||
<div | ||
style="margin:auto;max-height:100%" | ||
> | ||
<button | ||
style="border:1px solid #eee;border-radius:3px;background-color:#FFFFFF;cursor:pointer;font-size:15px;padding:3px 10px;margin:10px" | ||
type="button" | ||
> | ||
Hello Button | ||
</button> | ||
</div> | ||
</div> | ||
`; |
Oops, something went wrong.