@@ -39,6 +39,12 @@ const webpack = require('webpack');
39
39
* passed in, it is assigned to the "main" entry point, and the "polyfills"
40
40
* entry point will be added to it.
41
41
*
42
+ * @param {Boolean } ops.keepBuildInfo Optional. If `true` and a build info file
43
+ * from a previous build is found, the factory will use that rather than
44
+ * re-generating it. This provide the way to re-create webpack config at the
45
+ * server startup, without re-writing the build info generated previously
46
+ * during the bundling. Defaults to `false`.
47
+ *
42
48
* @param {String } ops.publicPath Base URL for the output of the build assets.
43
49
*/
44
50
module . exports = function configFactory ( ops ) {
@@ -47,20 +53,26 @@ module.exports = function configFactory(ops) {
47
53
publicPath : '' ,
48
54
} ) ;
49
55
50
- /* Stores misc build info into the local ".build-info" file in the context
51
- * directory. */
52
- const buildInfo = {
53
- /* A random 32-bit key, that can be used for encryption. */
54
- key : forge . random . getBytesSync ( 32 ) ,
56
+ let buildInfo ;
57
+ const buildInfoUrl = path . resolve ( o . context , '.build-info' ) ;
58
+ /* If build-info file is found, we reuse those data. */
59
+ if ( fs . existsSync ( buildInfoUrl ) && o . keepBuildInfo ) {
60
+ buildInfo = JSON . parse ( fs . readFileSync ( buildInfoUrl ) ) ;
61
+ } else {
62
+ /* Stores misc build info into the local ".build-info" file in the context
63
+ * directory. */
64
+ buildInfo = {
65
+ /* A random 32-bit key, that can be used for encryption. */
66
+ key : forge . random . getBytesSync ( 32 ) ,
55
67
56
- /* This will be equal to "development" or "production" */
57
- mode : ops . babelEnv ,
68
+ /* This will be equal to "development" or "production" */
69
+ mode : ops . babelEnv ,
58
70
59
- /* Build timestamp. */
60
- timestamp : moment . utc ( ) . toISOString ( ) ,
61
- } ;
62
- const buildInfoUrl = path . resolve ( o . context , '.build-info' ) ;
63
- fs . writeFileSync ( buildInfoUrl , JSON . stringify ( buildInfo ) ) ;
71
+ /* Build timestamp. */
72
+ timestamp : moment . utc ( ) . toISOString ( ) ,
73
+ } ;
74
+ fs . writeFileSync ( buildInfoUrl , JSON . stringify ( buildInfo ) ) ;
75
+ }
64
76
65
77
/* Entry points normalization. */
66
78
const entry = _ . isPlainObject ( o . entry )
@@ -72,7 +84,7 @@ module.exports = function configFactory(ops) {
72
84
entry . polyfills = _ . union ( entry . polyfills , [
73
85
'babel-polyfill' ,
74
86
'nodelist-foreach-polyfill' ,
75
- 'topcoder-react-utils/src/client' ,
87
+ 'topcoder-react-utils/src/client/init ' ,
76
88
] ) ;
77
89
return {
78
90
context : o . context ,
@@ -117,7 +129,7 @@ module.exports = function configFactory(ops) {
117
129
loader : 'file-loader' ,
118
130
options : {
119
131
outputPath : '/fonts/' ,
120
- publicPath : o . publicPath ,
132
+ publicPath : ` ${ o . publicPath } /fonts` ,
121
133
} ,
122
134
} , {
123
135
/* Loads JS and JSX moudles, and inlines SVG assets. */
@@ -135,7 +147,7 @@ module.exports = function configFactory(ops) {
135
147
loader : 'file-loader' ,
136
148
options : {
137
149
outputPath : '/images/' ,
138
- publicPath : o . publicPath ,
150
+ publicPath : ` ${ o . publicPath } /images` ,
139
151
} ,
140
152
} , {
141
153
/* Loads SCSS stylesheets. */
0 commit comments