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

Fixed regression: CSS entries were not picked up for storybook pages (e.g. when using exract-text-webpack-plugin) #1363

Merged
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
14 changes: 7 additions & 7 deletions app/react/src/server/iframe.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import url from 'url';
// 'preview.0d2d3d845f78399fd6d5e859daa152a9.css',
// 'static/preview.9adbb5ef965106be1cc3.bundle.js.map',
// 'preview.0d2d3d845f78399fd6d5e859daa152a9.css.map' ]
const urlsFromAssets = assets => {
export const urlsFromAssets = assets => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who uses this? does it need to be exported?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the tests, but for those it needs to be exported, yes.

if (!assets) {
return {
js: ['static/preview.bundle.js'],
Expand All @@ -26,13 +26,13 @@ const urlsFromAssets = assets => {
// Don't load the manager script in the iframe
.filter(key => key !== 'manager')
.forEach(key => {
const asset = assets[key];
if (typeof asset === 'string') {
urls[re.exec(asset)[1]].push(asset);
} else {
const assetUrl = asset.find(u => re.exec(u)[1] !== 'map');
urls[re.exec(assetUrl)[1]].push(assetUrl);
let assetList = assets[key];
if (!Array.isArray(assetList)) {
assetList = [assetList];
}
assetList.filter(assetUrl => re.exec(assetUrl)[1] !== 'map').forEach(assetUrl => {
urls[re.exec(assetUrl)[1]].push(assetUrl);
});
});

return urls;
Expand Down
21 changes: 21 additions & 0 deletions app/react/src/server/iframe.html.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { urlsFromAssets } from './iframe.html';

describe('server.urlsFromAssets', () => {
it('should return the default when there are no assets', () => {
expect(urlsFromAssets()).toEqual({
js: ['static/preview.bundle.js'],
css: [],
});
});

it('should return multiple assets', () => {
const fixture = {
manager: 'static/manager.a.bundle.js',
preview: ['static/preview.x.bundle.js', 'static/preview.y.css', 'static/preview.y.css.map'],
};
expect(urlsFromAssets(fixture)).toEqual({
js: ['static/preview.x.bundle.js'],
css: ['static/preview.y.css'],
});
});
});