-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Move more things to core #2788
Merged
Merged
Move more things to core #2788
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5a97466
Move default webpack.config to core
igor-dv d25cae6
use default webpack.config from core in angular app
igor-dv e821959
Move manager to core and use it in angular app
igor-dv 6832eda
Use core in polymer
igor-dv c059858
Use core in react
igor-dv 88844ba
Use core in vue
igor-dv 65f6391
Merge branch 'master' into move-more-things-to-core
igor-dv fd5454e
Merge branch 'master' into move-more-things-to-core
shilman 5bfd312
Rename + use object assign
igor-dv f7f4194
Merge branch 'master' into move-more-things-to-core
ndelangen 01bed1c
Merge branch 'master' into move-more-things-to-core
igor-dv ddbc05e
Merge branch 'master' into move-more-things-to-core
igor-dv 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 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 |
---|---|---|
@@ -1,73 +1,5 @@ | ||
// import webpack from 'webpack'; | ||
import autoprefixer from 'autoprefixer'; | ||
import { createDefaultWebpackConfig } from '@storybook/core/server'; | ||
import { includePaths } from '../utils'; | ||
|
||
// Add a default custom config which is similar to what React Create App does. | ||
module.exports = storybookBaseConfig => { | ||
const newConfig = { ...storybookBaseConfig }; | ||
|
||
newConfig.module.rules = [ | ||
...storybookBaseConfig.module.rules, | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
require.resolve('style-loader'), | ||
{ | ||
loader: require.resolve('css-loader'), | ||
options: { | ||
importLoaders: 1, | ||
}, | ||
}, | ||
{ | ||
loader: require.resolve('postcss-loader'), | ||
options: { | ||
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options | ||
plugins: () => [ | ||
require('postcss-flexbugs-fixes'), // eslint-disable-line | ||
autoprefixer({ | ||
browsers: [ | ||
'>1%', | ||
'last 4 versions', | ||
'Firefox ESR', | ||
'not ie < 9', // React doesn't support IE8 anyway | ||
], | ||
flexbox: 'no-2009', | ||
}), | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /\.json$/, | ||
include: includePaths, | ||
loader: require.resolve('json-loader'), | ||
}, | ||
{ | ||
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/, | ||
include: includePaths, | ||
loader: require.resolve('file-loader'), | ||
query: { | ||
name: 'static/media/[name].[hash:8].[ext]', | ||
}, | ||
}, | ||
{ | ||
test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/, | ||
include: includePaths, | ||
loader: require.resolve('url-loader'), | ||
query: { | ||
limit: 10000, | ||
name: 'static/media/[name].[hash:8].[ext]', | ||
}, | ||
}, | ||
]; | ||
|
||
newConfig.resolve.alias = { | ||
...storybookBaseConfig.resolve.alias, | ||
// This is to support NPM2 | ||
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator'), | ||
}; | ||
|
||
// Return the altered config | ||
return newConfig; | ||
}; | ||
module.exports = storybookBaseConfig => | ||
createDefaultWebpackConfig(storybookBaseConfig, includePaths); |
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 |
---|---|---|
@@ -1,17 +1 @@ | ||
// import deprecate from 'util-deprecate'; | ||
|
||
// NOTE export these to keep backwards compatibility | ||
// import { action as deprecatedAction } from '@storybook/addon-actions'; | ||
// import { linkTo as deprecatedLinkTo } from '@storybook/addon-links'; | ||
|
||
export { storiesOf, setAddon, addDecorator, configure, getStorybook } from './preview'; | ||
|
||
// export const action = deprecate( | ||
// deprecatedAction, | ||
// '@storybook/react action is deprecated. See: https://github.com/storybooks/storybook/tree/master/addons/actions' | ||
// ); | ||
|
||
// export const linkTo = deprecate( | ||
// deprecatedLinkTo, | ||
// '@storybook/react linkTo is deprecated. See: https://github.com/storybooks/storybook/tree/master/addons/links' | ||
// ); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,73 +1,5 @@ | ||
// import webpack from 'webpack'; | ||
import autoprefixer from 'autoprefixer'; | ||
import { createDefaultWebpackConfig } from '@storybook/core/server'; | ||
import { includePaths } from '../utils'; | ||
|
||
// Add a default custom config which is similar to what React Create App does. | ||
module.exports = storybookBaseConfig => { | ||
const newConfig = { ...storybookBaseConfig }; | ||
|
||
newConfig.module.rules = [ | ||
...storybookBaseConfig.module.rules, | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
require.resolve('style-loader'), | ||
{ | ||
loader: require.resolve('css-loader'), | ||
options: { | ||
importLoaders: 1, | ||
}, | ||
}, | ||
{ | ||
loader: require.resolve('postcss-loader'), | ||
options: { | ||
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options | ||
plugins: () => [ | ||
require('postcss-flexbugs-fixes'), // eslint-disable-line | ||
autoprefixer({ | ||
browsers: [ | ||
'>1%', | ||
'last 4 versions', | ||
'Firefox ESR', | ||
'not ie < 9', // React doesn't support IE8 anyway | ||
], | ||
flexbox: 'no-2009', | ||
}), | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /\.json$/, | ||
include: includePaths, | ||
loader: require.resolve('json-loader'), | ||
}, | ||
{ | ||
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/, | ||
include: includePaths, | ||
loader: require.resolve('file-loader'), | ||
query: { | ||
name: 'static/media/[name].[hash:8].[ext]', | ||
}, | ||
}, | ||
{ | ||
test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/, | ||
include: includePaths, | ||
loader: require.resolve('url-loader'), | ||
query: { | ||
limit: 10000, | ||
name: 'static/media/[name].[hash:8].[ext]', | ||
}, | ||
}, | ||
]; | ||
|
||
newConfig.resolve.alias = { | ||
...storybookBaseConfig.resolve.alias, | ||
// This is to support NPM2 | ||
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator'), | ||
}; | ||
|
||
// Return the altered config | ||
return newConfig; | ||
}; | ||
module.exports = storybookBaseConfig => | ||
createDefaultWebpackConfig(storybookBaseConfig, includePaths); |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
How about moving the webpack configs into a separate package?
So this becomes much easier:
https://storybook.js.org/configurations/custom-webpack-config/#full-control-mode--default
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.
What do you mean? Will it be something like
@storybook/configs
? TBH, I think we need to make some progress in core extraction because this copypasta across all the apps makes me crazy 😷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.
@storybook/webpack-config
sounds good to me. We only need to publish the default one, because it's the only one that should be imported from outsideThere 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.
But maybe it would be an even better solution just to pass genDefaultConfig as third argument to custom webpack config function, so that users could write full control + defaults like this, without any extra imports:
Or maybe even like this:
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.
Makes sense to me. It's way much simpler than publishing one more package
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.
I mean from the user's point of view =)
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.
I'd rather not create yet another package. @Hypnosphi the proposals above seem pretty reasonable--are they backwards compatible or breaking changes?
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.
@shilman We should deprecate the old way using
utils-deprecate
for now, and then remove it in next majorSo the answer is yes, it can be backwards-compatible