Skip to content

fixes #3 make sure publicPath must end with slash #4

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

Merged
merged 1 commit into from
Oct 9, 2017
Merged
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: 13 additions & 1 deletion packages/create-react-scripts-ssr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ const fs = require('fs');
const path = require('path');
const AssetsPlugin = require('assets-webpack-plugin');


function ensureSlash(path, needsSlash) {
const hasSlash = path.endsWith('/');
if (hasSlash && !needsSlash) {
return path.substr(path, path.length - 1);
} else if (!hasSlash && needsSlash) {
return `${path}/`;
} else {
return path;
}
}

module.exports = () => ({
paths(paths) {
// we need to make it compatiable to create-react-scripts-typescript
Expand Down Expand Up @@ -55,7 +67,7 @@ module.exports = () => ({
fullPath: true,
processOutput: (assets) => {
Object.values(assets).forEach(mod => {
if (mod.js) mod.js = config.output.publicPath + path.join(pluginOptions.path || '', mod.js);
if (mod.js) mod.js = ensureSlash(config.output.publicPath, true) + path.join(pluginOptions.path || '', mod.js);
});
return JSON.stringify(assets);
}
Expand Down