mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 01:11:08 +08:00
Remove "defaultConfigName" prop and use "defaultConfig" as a single config to be extended
This commit is contained in:
parent
3a06253e01
commit
cb15153810
1
app/angular/src/server/options.js
vendored
1
app/angular/src/server/options.js
vendored
@ -2,7 +2,6 @@ import packageJson from '../../package.json';
|
||||
|
||||
export default {
|
||||
packageJson,
|
||||
defaultConfigName: 'angular-cli',
|
||||
frameworkPresets: [
|
||||
require.resolve('./framework-preset-angular.js'),
|
||||
require.resolve('./framework-preset-angular-cli.js'),
|
||||
|
@ -2,6 +2,5 @@ import packageJson from '../../package.json';
|
||||
|
||||
export default {
|
||||
packageJson,
|
||||
defaultConfigName: 'ember-cli',
|
||||
frameworkPresets: [require.resolve('./framework-preset-babel-ember.js')],
|
||||
};
|
||||
|
@ -2,7 +2,6 @@ import packageJson from '../../package.json';
|
||||
|
||||
export default {
|
||||
packageJson,
|
||||
defaultConfigName: 'create-react-app',
|
||||
frameworkPresets: [
|
||||
require.resolve('./framework-preset-react.js'),
|
||||
require.resolve('./framework-preset-cra.js'),
|
||||
|
@ -1,12 +1,14 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -1,12 +1,14 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../stories')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../stories')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -1,12 +1,14 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -1,12 +1,14 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -1,16 +1,16 @@
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
// TEMP fix: https://github.com/plotly/plotly.js/issues/2466#issuecomment-372924684
|
||||
defaultConfig.plugins.push(new webpack.IgnorePlugin(/vertx/));
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [new webpack.IgnorePlugin(/vertx/)],
|
||||
};
|
||||
|
@ -1,17 +1,18 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
defaultConfig.module.rules.push({
|
||||
test: /\.txt$/,
|
||||
use: 'raw-loader',
|
||||
});
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
{
|
||||
test: /\.txt$/,
|
||||
use: 'raw-loader',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -1,12 +1,14 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -1,12 +1,14 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = (storybookBaseConfig, configType, defaultConfig) => {
|
||||
defaultConfig.module.rules.push({
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
});
|
||||
|
||||
return defaultConfig;
|
||||
module.exports = {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: [/\.stories\.js$/, /index\.js$/],
|
||||
loaders: [require.resolve('@storybook/addon-storysource/loader')],
|
||||
include: [path.resolve(__dirname, '../src')],
|
||||
enforce: 'pre',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -3,40 +3,31 @@ import loadCustomWebpackConfig from '../utils/load-custom-webpack-config';
|
||||
import mergeConfigs from '../utils/merge-webpack-config';
|
||||
import { createDefaultWebpackConfig } from './base-webpack.config';
|
||||
|
||||
function logConfigName(defaultConfigName) {
|
||||
if (!defaultConfigName) {
|
||||
logger.info('=> Using default webpack setup.');
|
||||
} else {
|
||||
logger.info(`=> Using default webpack setup based on "${defaultConfigName}".`);
|
||||
}
|
||||
}
|
||||
|
||||
async function createFinalDefaultConfig(presets, config, options) {
|
||||
const defaultConfig = createDefaultWebpackConfig(config);
|
||||
return presets.apply('webpackFinal', defaultConfig, options);
|
||||
}
|
||||
|
||||
export async function webpack(config, options) {
|
||||
const { configDir, configType, defaultConfigName, presets } = options;
|
||||
const { configDir, configType, presets } = options;
|
||||
|
||||
const finalConfig = await presets.apply('webpackFinal', config, options);
|
||||
const finalDefaultConfig = await createFinalDefaultConfig(presets, config, options);
|
||||
|
||||
// Check whether user has a custom webpack config file and
|
||||
// return the (extended) base configuration if it's not available.
|
||||
const customConfig = loadCustomWebpackConfig(configDir);
|
||||
|
||||
if (customConfig === null) {
|
||||
logConfigName(defaultConfigName);
|
||||
return createFinalDefaultConfig(presets, config, options);
|
||||
logger.info('=> Using default webpack setup.');
|
||||
return finalDefaultConfig;
|
||||
}
|
||||
|
||||
if (typeof customConfig === 'function') {
|
||||
logger.info('=> Loading custom webpack config (full-control mode).');
|
||||
const finalDefaultConfig = await createFinalDefaultConfig(presets, config, options);
|
||||
return customConfig(finalConfig, configType, finalDefaultConfig);
|
||||
return customConfig({ config: finalDefaultConfig, configType });
|
||||
}
|
||||
|
||||
logger.info('=> Loading custom webpack config (extending mode).');
|
||||
|
||||
return mergeConfigs(finalConfig, customConfig);
|
||||
return mergeConfigs(finalDefaultConfig, customConfig);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user