@@ -31,6 +31,8 @@ const getClientEnvironment = require('./env');
3131const  ModuleNotFoundPlugin  =  require ( 'react-dev-utils/ModuleNotFoundPlugin' ) ; 
3232const  ForkTsCheckerWebpackPlugin  =  require ( 'fork-ts-checker-webpack-plugin-alt' ) ; 
3333const  typescriptFormatter  =  require ( 'react-dev-utils/typescriptFormatter' ) ; 
34+ const  CopyWebpackPlugin  =  require ( 'copy-webpack-plugin' ) ; 
35+ 
3436// @remove -on-eject-begin 
3537const  getCacheIdentifier  =  require ( 'react-dev-utils/getCacheIdentifier' ) ; 
3638// @remove -on-eject-end 
@@ -44,6 +46,9 @@ const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
4446// Check if TypeScript is setup 
4547const  useTypeScript  =  fs . existsSync ( paths . appTsConfig ) ; 
4648
49+ // FS - check if hf is installed in root node_modules 
50+ const  isHF  =  fs . existsSync ( path . join ( paths . appNodeModules ,  'hf/webpack.config.js' ) ) ; 
51+ 
4752// style files regexes 
4853const  cssRegex  =  / \. c s s $ / ; 
4954const  cssModuleRegex  =  / \. m o d u l e \. c s s $ / ; 
@@ -237,12 +242,15 @@ module.exports = function(webpackEnv) {
237242      // https://twitter.com/wSokra/status/969633336732905474 
238243      // https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366 
239244      splitChunks : { 
240-         chunks : 'all' , 
245+         // FS - split chunks was causing issues for webpacked hf build, async fixes it so that it doesn't 
246+         // try to use the same chunks for async/non-async assets 
247+         chunks : isHF  ? 'async'  : 'all' , 
241248        name : false , 
242249      } , 
243250      // Keep the runtime chunk separated to enable long term caching 
244251      // https://twitter.com/wSokra/status/969679223278505985 
245-       runtimeChunk : true , 
252+       // FS - Turn off for hf since it causes issues with imports in hf js files. 
253+       runtimeChunk : ! isHF , 
246254    } , 
247255    resolve : { 
248256      // This allows you to set a fallback for where Webpack should look for modules. 
@@ -512,12 +520,23 @@ module.exports = function(webpackEnv) {
512520      ] , 
513521    } , 
514522    plugins : [ 
523+       // FS - copy over hf's webpack built files to /static/hf directory to be 
524+       // used by snow. 
525+       isHF  && 
526+         new  CopyWebpackPlugin ( [ 
527+           { 
528+             from : path . join ( paths . appNodeModules ,  `hf/dist/${ isEnvProduction  ? 'prod'  : 'dev' }  ` ) , 
529+             to : 'static/hf/[name].[ext]' , 
530+             toType : 'template' , 
531+           } , 
532+         ] ) , 
515533      // Generates an `index.html` file with the <script> injected. 
516534      new  HtmlWebpackPlugin ( 
517535        Object . assign ( 
518536          { } , 
519537          { 
520538            inject : true , 
539+             filename : isHF  ? '_index.html'  : 'index.html' , 
521540            template : paths . appHtml , 
522541          } , 
523542          isEnvProduction 
0 commit comments