Skip to content

Commit 78337cd

Browse files
authored
Merge pull request #4 from raymondsze/fix-dll-publicPath
fixes #3 make sure publicPath must end with slash
2 parents 1c2e0d0 + bb488c3 commit 78337cd

File tree

1 file changed

+13
-1
lines changed
  • packages/create-react-scripts-ssr

1 file changed

+13
-1
lines changed

packages/create-react-scripts-ssr/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ const fs = require('fs');
44
const path = require('path');
55
const AssetsPlugin = require('assets-webpack-plugin');
66

7+
8+
function ensureSlash(path, needsSlash) {
9+
const hasSlash = path.endsWith('/');
10+
if (hasSlash && !needsSlash) {
11+
return path.substr(path, path.length - 1);
12+
} else if (!hasSlash && needsSlash) {
13+
return `${path}/`;
14+
} else {
15+
return path;
16+
}
17+
}
18+
719
module.exports = () => ({
820
paths(paths) {
921
// we need to make it compatiable to create-react-scripts-typescript
@@ -55,7 +67,7 @@ module.exports = () => ({
5567
fullPath: true,
5668
processOutput: (assets) => {
5769
Object.values(assets).forEach(mod => {
58-
if (mod.js) mod.js = config.output.publicPath + path.join(pluginOptions.path || '', mod.js);
70+
if (mod.js) mod.js = ensureSlash(config.output.publicPath, true) + path.join(pluginOptions.path || '', mod.js);
5971
});
6072
return JSON.stringify(assets);
6173
}

0 commit comments

Comments
 (0)