File tree 1 file changed +13
-1
lines changed
packages/create-react-scripts-ssr
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,18 @@ const fs = require('fs');
4
4
const path = require ( 'path' ) ;
5
5
const AssetsPlugin = require ( 'assets-webpack-plugin' ) ;
6
6
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
+
7
19
module . exports = ( ) => ( {
8
20
paths ( paths ) {
9
21
// we need to make it compatiable to create-react-scripts-typescript
@@ -55,7 +67,7 @@ module.exports = () => ({
55
67
fullPath : true ,
56
68
processOutput : ( assets ) => {
57
69
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 ) ;
59
71
} ) ;
60
72
return JSON . stringify ( assets ) ;
61
73
}
You can’t perform that action at this time.
0 commit comments