简体   繁体   English

带有路由的Webpack生产版本无法加载1.bundle.js文件

[英]Webpack production build with routing not load 1.bundle.js file

I have a test repo for this problem ( Link ) 我有一个针对此问题的测试仓库( Link

I think it's a problem with localization file. 我认为这是本地化文件的问题。 I use react-intl. 我使用react-intl。

Dev version works good. 开发版本效果很好。

The problem is: 问题是:

  • create production build 创建生产版本
  • run production server 运行生产服务器
  • open app http://localhost:3001/activities 打开应用程序http:// localhost:3001 / activities
  • refresh page (works normal) 刷新页面(正常工作)
  • click on Link to id 1 (works normal) 点击链接到ID 1 (正常工作)
  • refresh page (not work, because 1.bundle.js file not sent correctly, css too) 刷新页面(不起作用,因为1.bundle.js文件未正确发送,css也是如此)

What is 1.bundle.js ? 什么是1.bundle.js I think it is localization file. 我认为这是本地化文件。 ( some info ). 一些信息 )。 How I can fix it? 我该如何解决?

The problem was in production config. 问题出在生产配置中。 I forgot publicPath setting. 我忘记了publicPath设置。

...
output: {
  path: path.join(__dirname, 'production/public/'),
  filename: 'bundle.js',
  publicPath: '/' // this will make sure that all statics are hit at '/' route
},
...

Pull request link 拉取请求链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM