Skip to content

Commit

Permalink
Also update dist
Browse files Browse the repository at this point in the history
  • Loading branch information
romeovs committed Feb 1, 2017
1 parent 69ebcac commit e27c227
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports.default = function (configType, baseConfig, configDir) {
})
});

addJsonLoaderIfNotAvailable(newConfig);
// addJsonLoaderIfNotAvailable(newConfig);

return newConfig;
};
Expand Down
22 changes: 17 additions & 5 deletions dist/server/config/defaults/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ var _autoprefixer2 = _interopRequireDefault(_autoprefixer);

var _utils = require('../utils');

var _webpack = require('webpack');

var _webpack2 = _interopRequireDefault(_webpack);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// Add a default custom config which is similar to what React Create App does.
Expand Down Expand Up @@ -44,11 +48,19 @@ module.exports = function (storybookBaseConfig) {
}
}]);

newConfig.postcss = function () {
return [(0, _autoprefixer2.default)({
browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9']
})];
};
var postcssPlugins = [(0, _autoprefixer2.default)({
browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9']
})];

if (_utils.webpackVersion === 1) {
newConfig.postcss = function () {
return postcssPlugins;
};
} else {
newConfig.plugins.push(new _webpack2.default.LoaderOptionsPlugin({
postcss: postcssPlugins
}));
}

newConfig.resolve.alias = (0, _extends3.default)({}, storybookBaseConfig.resolve.alias, {
// This is to support NPM2
Expand Down
4 changes: 3 additions & 1 deletion dist/server/config/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.nodePaths = exports.nodeModulesPaths = exports.excludePaths = exports.includePaths = exports.OccurenceOrderPlugin = undefined;
exports.nodePaths = exports.nodeModulesPaths = exports.excludePaths = exports.includePaths = exports.webpackVersion = exports.OccurenceOrderPlugin = undefined;

var _stringify = require('babel-runtime/core-js/json/stringify');

Expand Down Expand Up @@ -31,6 +31,8 @@ exports.OccurenceOrderPlugin = _webpack2.default.optimize.OccurrenceOrderPlugin
// for webpack 1
_webpack2.default.optimize.OccurenceOrderPlugin;

var webpackVersion = exports.webpackVersion = _webpack2.default.optimize.OccurrenceOrderPlugin ? 2 : 1;

var includePaths = exports.includePaths = [_path2.default.resolve('./')];

var excludePaths = exports.excludePaths = [_path2.default.resolve('./node_modules')];
Expand Down
12 changes: 8 additions & 4 deletions dist/server/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ exports.default = function () {
resolve: {
// Since we ship with json-loader always, it's better to move extensions to here
// from the default config.
extensions: ['.js', '.json', '.jsx', ''],
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
fallback: _utils.nodePaths,
extensions: ['.js', '.json', '.jsx'],
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
}
}
};

if (_utils.webpackVersion === 1) {
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
config.fallback = _utils.nodePaths;
config.resolve.extensions.push('');
}

return config;
};

Expand Down
12 changes: 8 additions & 4 deletions dist/server/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ exports.default = function () {
resolve: {
// Since we ship with json-loader always, it's better to move extensions to here
// from the default config.
extensions: ['.js', '.json', '.jsx', ''],
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
fallback: _utils.nodePaths,
extensions: ['.js', '.json', '.jsx'],
alias: {
// This is to add addon support for NPM2
'@kadira/storybook-addons': require.resolve('@kadira/storybook-addons')
Expand All @@ -63,6 +60,13 @@ exports.default = function () {
config.plugins.unshift(new _utils.OccurenceOrderPlugin());
}

if (webpackVersion === 1) {
// Add support to NODE_PATH. With this we could avoid relative path imports.
// Based on this CRA feature: https://github.com/facebookincubator/create-react-app/issues/253
config.fallback = _utils.nodePaths;
config.resolve.extensions.push('');
}

return config;
};

Expand Down
8 changes: 7 additions & 1 deletion dist/server/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ exports.default = function (configDir) {
publicPath = publicPath.slice(1);
}

var compiler = (0, _webpack2.default)(config);
var compiler = void 0;
try {
compiler = (0, _webpack2.default)(config);
} catch (err) {
console.log(err);
}

var devMiddlewareOptions = {
noInfo: true,
publicPath: config.output.publicPath,
Expand Down

0 comments on commit e27c227

Please sign in to comment.