Skip to content

Commit

Permalink
Add @kadira/storybook-addons into resolve.alias. (#462)
Browse files Browse the repository at this point in the history
Then addons will work on NPM2 properly.
  • Loading branch information
arunoda authored Sep 19, 2016
1 parent 82cace8 commit 18ac324
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 19 deletions.
Empty file modified dist/server/build.js
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions dist/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ exports.default = function (configType, baseConfig, configDir) {
plugins: [].concat((0, _toConsumableArray3.default)(config.plugins), (0, _toConsumableArray3.default)(customConfig.plugins || [])),
module: (0, _extends3.default)({}, config.module, customConfig.module, {
loaders: [].concat((0, _toConsumableArray3.default)(config.module.loaders), (0, _toConsumableArray3.default)(customConfig.module.loaders || []))
}),
resolve: (0, _extends3.default)({}, customConfig.resolve, {
alias: (0, _extends3.default)({}, config.alias, customConfig.alias)
})
});
};
Expand Down
21 changes: 11 additions & 10 deletions dist/server/config/defaults/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _autoprefixer = require('autoprefixer');

var _autoprefixer2 = _interopRequireDefault(_autoprefixer);
Expand All @@ -14,8 +18,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de

// Add a default custom config which is similar to what React Create App does.
module.exports = function (storybookBaseConfig) {
var newConfig = storybookBaseConfig;
newConfig.module.loaders = [].concat((0, _toConsumableArray3.default)(newConfig.module.loaders), [{
var newConfig = (0, _extends3.default)({}, storybookBaseConfig);
newConfig.module.loaders = [].concat((0, _toConsumableArray3.default)(storybookBaseConfig.module.loaders), [{
test: /\.css?$/,
include: _utils.includePaths,
loaders: [require.resolve('style-loader'), require.resolve('css-loader'), require.resolve('postcss-loader')]
Expand Down Expand Up @@ -46,14 +50,11 @@ module.exports = function (storybookBaseConfig) {
})];
};

newConfig.resolve = {
// These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''],
alias: {
// This is to support NPM2
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator')
}
};
newConfig.resolve.extensions = ['.js', '.json', ''];
newConfig.resolve.alias = (0, _extends3.default)({}, storybookBaseConfig.resolve.alias, {
// This is to support NPM2
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator')
});

// Return the altered config
return newConfig;
Expand Down
6 changes: 6 additions & 0 deletions dist/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ var config = {
include: _utils.includePaths,
exclude: _utils.excludePaths
}]
},
resolve: {
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
}
}
};

Expand Down
6 changes: 6 additions & 0 deletions dist/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ var config = {
include: _utils.includePaths,
exclude: _utils.excludePaths
}]
},
resolve: {
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
}
}
};

Expand Down
7 changes: 7 additions & 0 deletions src/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,12 @@ export default function (configType, baseConfig, configDir) {
...customConfig.module.loaders || [],
],
},
resolve: {
...customConfig.resolve,
alias: {
...config.alias,
...customConfig.alias,
}
}
};
}
16 changes: 7 additions & 9 deletions src/server/config/defaults/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { includePaths } from '../utils';

// Add a default custom config which is similar to what React Create App does.
module.exports = (storybookBaseConfig) => {
const newConfig = storybookBaseConfig;
const newConfig = { ...storybookBaseConfig };
newConfig.module.loaders = [
...newConfig.module.loaders,
...storybookBaseConfig.module.loaders,
{
test: /\.css?$/,
include: includePaths,
Expand Down Expand Up @@ -52,13 +52,11 @@ module.exports = (storybookBaseConfig) => {
];
};

newConfig.resolve = {
// These are the reasonable defaults supported by the Node ecosystem.
extensions: ['.js', '.json', ''],
alias: {
// This is to support NPM2
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator'),
},
newConfig.resolve.extensions = ['.js', '.json', ''];
newConfig.resolve.alias = {
...storybookBaseConfig.resolve.alias,
// This is to support NPM2
'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator'),
};

// Return the altered config
Expand Down
6 changes: 6 additions & 0 deletions src/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const config = {
},
],
},
resolve: {
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons'),
}
}
};

export default config;
6 changes: 6 additions & 0 deletions src/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ const config = {
},
],
},
resolve: {
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons'),
}
}
};

// Webpack 2 doesn't have a OccurenceOrderPlugin plugin in the production mode.
Expand Down

0 comments on commit 18ac324

Please sign in to comment.