@@ -25,6 +25,11 @@ const webpack = require('webpack');
25
25
*
26
26
* @param {String } ops.babelEnv BABEL_ENV to use for Babel during the build.
27
27
*
28
+ * @param {String } ops.cdnPublicPath Optional. If provided, it will be used in
29
+ * the frontend bundle instead of publicPath, to direct all asset request to
30
+ * CDN. The publicPath still will be used by the server as the path to serve
31
+ * the assets for CDN requests.
32
+ *
28
33
* @param {String } ops.context Base URL for resolution of relative
29
34
* config paths.
30
35
*
@@ -50,9 +55,10 @@ const webpack = require('webpack');
50
55
module . exports = function configFactory ( ops ) {
51
56
const o = _ . defaults ( _ . clone ( ops ) , {
52
57
cssLocalIdent : '[hash:base64:6]' ,
53
- publicPath : '' ,
54
58
} ) ;
55
59
60
+ const publicPath = o . cdnPublicPath || o . publicPath || '' ;
61
+
56
62
let buildInfo ;
57
63
const buildInfoUrl = path . resolve ( o . context , '.build-info' ) ;
58
64
/* If build-info file is found, we reuse those data. */
@@ -97,7 +103,7 @@ module.exports = function configFactory(ops) {
97
103
chunkFilename : '[name].js' ,
98
104
filename : '[name].js' ,
99
105
path : path . resolve ( __dirname , o . context , 'build' ) ,
100
- publicPath : `${ o . publicPath } /` ,
106
+ publicPath : `${ publicPath } /` ,
101
107
} ,
102
108
plugins : [
103
109
new ExtractCssChunks ( {
@@ -129,7 +135,7 @@ module.exports = function configFactory(ops) {
129
135
loader : 'file-loader' ,
130
136
options : {
131
137
outputPath : '/fonts/' ,
132
- publicPath : `${ o . publicPath } /fonts` ,
138
+ publicPath : `${ publicPath } /fonts` ,
133
139
} ,
134
140
} , {
135
141
/* Loads JS and JSX moudles, and inlines SVG assets. */
@@ -147,7 +153,7 @@ module.exports = function configFactory(ops) {
147
153
loader : 'file-loader' ,
148
154
options : {
149
155
outputPath : '/images/' ,
150
- publicPath : `${ o . publicPath } /images` ,
156
+ publicPath : `${ publicPath } /images` ,
151
157
} ,
152
158
} , {
153
159
/* Loads SCSS stylesheets. */
0 commit comments