带有url params的url在具有多个入口点的create-react-app-rewired app中无法解析

时间:2018-04-07 17:40:10

标签: webpack create-react-app html-webpack-plugin

我在config-override.js文件中有以下配置来实现多个入口点。

config.entry = {
    index: [
      config.entry[0],  // polyfill.js
      paths.appSrc + '/entryPoints/somePath1/AppPage1.tsx'
    ],
    appPage1: [
      config.entry[0],  // polyfill.js
      paths.appSrc + '/entryPoints/somePath1/AppPage1.tsx'
   ],
  appPage2: [
     config.entry[0],  // polyfill.js
     paths.appSrc + '/entryPoints/somePath2/AppPage2.tsx'
  ],
 ...
}


new HtmlWebpackPlugin({
  hash: true,
  template: paths.appHtml,
  chunks: ['index'],
  filename: paths.appBuild + '/index.html'
}),
new HtmlWebpackPlugin({
  hash: true,
  template: paths.appHtml,
  chunks: ['appPage1'],
  filename: paths.appBuild + '/page1/index.html'
}),
new HtmlWebpackPlugin({
  hash: true,
  template: paths.appPublic + '/page2.html',
  chunks: ['appPage2'],
  filename: paths.appBuild + '/abc/page2.html'
})

我遇到的问题是网址http://localhost:5000/abc/page2.html有效但http://localhost:5000/abc/page2.html?someUrlParam=someValue导致返回错误的网页/条目(第1页)。

如果我为网址http://localhost:5000/abc/page2.html?someUrlParam=someValue进行了硬刷新,它在普通镀铬窗口中按预期工作,但在隐身模式下不能正常工作。

我在弹出后使用等效入口点和HtmlWebpackPlugin条目获得相同的行为。

更新: 问题由unregistering服务工作者解决了。

但不清楚为什么删除url params会导致预期的行为。 可能会跟随webpack.config.prod.js中的评论与其有关

// By default, a cache-busting query parameter is appended to requests // used to populate the caches, to ensure the responses are fresh. // If a URL is already hashed by Webpack, then there is no concern // about it being stale, and the cache-busting can be skipped

0 个答案:

没有答案