Skip to content
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

Using file-loader to load all the extensions. #653

Merged
merged 1 commit into from
Dec 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/client/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var _global = global,
navigator = _global.navigator; /* global window */

var isBrowser = navigator && navigator.userAgent !== 'storyshots';
var isBrowser = navigator && navigator.userAgent !== 'storyshots' && !navigator.userAgent.includes('Node.js');

var storyStore = new _story_store2.default();
var reduxStore = (0, _redux.createStore)(_reducer2.default);
Expand Down
27 changes: 11 additions & 16 deletions dist/server/config/defaults/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,24 @@ 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 = (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') + '?importLoaders=1', require.resolve('postcss-loader')]
}, {
test: /\.json$/,
include: _utils.includePaths,
loader: require.resolve('json-loader')
}, {
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2)(\?.*)?$/,
newConfig.module.loaders = [].concat((0, _toConsumableArray3.default)(storybookBaseConfig.module.loaders), [
// This loads all other assets using the file-loader except for
// the excluded extentions. Because they have their own loaders.
{
include: _utils.includePaths,
exclude: [/\.html$/, /\.(js|jsx)$/, /\.css$/, /\.json$/],
loader: require.resolve('file-loader'),
query: {
name: 'static/media/[name].[hash:8].[ext]'
}
}, {
test: /\.(mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
test: /\.css?$/,
include: _utils.includePaths,
loader: require.resolve('url-loader'),
query: {
limit: 10000,
name: 'static/media/[name].[hash:8].[ext]'
}
loaders: [require.resolve('style-loader'), require.resolve('css-loader') + '?importLoaders=1', require.resolve('postcss-loader')]
}, {
test: /\.json$/,
include: _utils.includePaths,
loader: require.resolve('json-loader')
}]);

newConfig.postcss = function () {
Expand Down
32 changes: 15 additions & 17 deletions src/server/config/defaults/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ module.exports = (storybookBaseConfig) => {
const newConfig = { ...storybookBaseConfig };
newConfig.module.loaders = [
...storybookBaseConfig.module.loaders,
// This loads all other assets using the file-loader except for
// the excluded extentions. Because they have their own loaders.
{
include: includePaths,
exclude: [
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.json$/,
],
loader: require.resolve('file-loader'),
query: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
{
test: /\.css?$/,
include: includePaths,
Expand All @@ -20,23 +35,6 @@ module.exports = (storybookBaseConfig) => {
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.postcss = () => {
Expand Down