Skip to content

Commit 84e3e23

Browse files
committed
Make bundle location relative to webpack publicPath
1 parent 5418de1 commit 84e3e23

10 files changed

Lines changed: 29 additions & 28 deletions

File tree

dist/manager.js

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/manager.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/server/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ var config = (0, _config2.default)('PRODUCTION', _webpackConfig2.default, config
6363

6464
// Write both the storybook UI and IFRAME HTML files to destination path.
6565
var headHtml = (0, _utils.getHeadHtml)(configDir);
66-
_fs2.default.writeFileSync(_path2.default.resolve(outputDir, 'index.html'), (0, _index2.default)());
67-
_fs2.default.writeFileSync(_path2.default.resolve(outputDir, 'iframe.html'), (0, _iframe2.default)(headHtml));
66+
_fs2.default.writeFileSync(_path2.default.resolve(outputDir, 'index.html'), (0, _index2.default)(config.output.publicPath));
67+
_fs2.default.writeFileSync(_path2.default.resolve(outputDir, 'iframe.html'), (0, _iframe2.default)(headHtml, config.output.publicPath));
6868

6969
// copy all static files
7070
if (_commander2.default.staticDir) {

dist/server/iframe.html.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
66

7-
exports.default = function (headHtml) {
8-
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <script>\n if (window.parent !== window) {\n window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n }\n </script>\n <title>React Storybook</title>\n " + headHtml + "\n </head>\n <body>\n <div id=\"root\"></div>\n <script src=\"static/preview.bundle.js\"></script>\n </body>\n </html>\n ";
7+
exports.default = function (headHtml, publicPath) {
8+
return "\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <script>\n if (window.parent !== window) {\n window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;\n }\n </script>\n <title>React Storybook</title>\n " + headHtml + "\n </head>\n <body>\n <div id=\"root\"></div>\n <script src=\"" + publicPath + "preview.bundle.js\"></script>\n </body>\n </html>\n ";
99
};

dist/server/index.html.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/server/middleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ exports.default = function (configDir) {
1919
router.use((0, _webpackHotMiddleware2.default)(compiler));
2020

2121
router.get('/', function (req, res) {
22-
res.send((0, _index2.default)());
22+
res.send((0, _index2.default)(config.output.publicPath));
2323
});
2424

2525
var headHtml = (0, _utils.getHeadHtml)(configDir);
2626
router.get('/iframe.html', function (req, res) {
27-
res.send((0, _iframe2.default)(headHtml));
27+
res.send((0, _iframe2.default)(headHtml, config.output.publicPath));
2828
});
2929

3030
return router;

src/server/build.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ const config = loadConfig('PRODUCTION', baseConfig, configDir);
3535

3636
// Write both the storybook UI and IFRAME HTML files to destination path.
3737
const headHtml = getHeadHtml(configDir);
38-
fs.writeFileSync(path.resolve(outputDir, 'index.html'), getIndexHtml());
39-
fs.writeFileSync(path.resolve(outputDir, 'iframe.html'), getIframeHtml(headHtml));
38+
fs.writeFileSync(path.resolve(outputDir, 'index.html'), getIndexHtml(config.output.publicPath));
39+
fs.writeFileSync(path.resolve(outputDir, 'iframe.html'),
40+
getIframeHtml(headHtml, config.output.publicPath));
4041

4142
// copy all static files
4243
if (program.staticDir) {

src/server/iframe.html.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function (headHtml) {
1+
export default function (headHtml, publicPath) {
22
return `
33
<!DOCTYPE html>
44
<html>
@@ -15,7 +15,7 @@ export default function (headHtml) {
1515
</head>
1616
<body>
1717
<div id="root"></div>
18-
<script src="static/preview.bundle.js"></script>
18+
<script src="${publicPath}preview.bundle.js"></script>
1919
</body>
2020
</html>
2121
`;

src/server/index.html.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function () {
1+
export default function (publicPath) {
22
return `
33
<!DOCTYPE html>
44
<html>
@@ -38,7 +38,7 @@ export default function () {
3838
</head>
3939
<body style="margin: 0;">
4040
<div id="root"></div>
41-
<script src="static/manager.bundle.js"></script>
41+
<script src="${publicPath}manager.bundle.js"></script>
4242
</body>
4343
</html>
4444
`;

src/server/middleware.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export default function (configDir) {
2323
router.use(webpackHotMiddleware(compiler));
2424

2525
router.get('/', function (req, res) {
26-
res.send(getIndexHtml());
26+
res.send(getIndexHtml(config.output.publicPath));
2727
});
2828

2929
const headHtml = getHeadHtml(configDir);
3030
router.get('/iframe.html', function (req, res) {
31-
res.send(getIframeHtml(headHtml));
31+
res.send(getIframeHtml(headHtml, config.output.publicPath));
3232
});
3333

3434
return router;

0 commit comments

Comments
 (0)