Create-react-app: How to change output filename of runtime chunk?

Created on 8 Oct 2018  路  10Comments  路  Source: facebook/create-react-app

currently the output is runtime~xxx.[hash].js

How do I change that? I can't make it work on cloudfront to serve files with ~ in the filename...

Example:
S3: https://s3.eu-central-1.amazonaws.com/timesheet-app.topmonks.com/static/js/runtime~main.229c360f.js Works
CF: https://timesheet-app.topmonks.com/static/js/runtime~main.229c360f.js doesn't work

Thanks a lot

Edit:
Proposed changes:

webpack.prod InlineChunkHtmlPlugin

new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime-.+[.]js/])

webpack.prod runtimeChunk

runtimeChunk: { 
    name: entrypoint => `runtime-${entrypoint.name}`,
},

Edit: seems like the cloudfront link somehow works now, anyway I would perform the change anyway as imo ~ is not the best idea for file naming.

proposal

Most helpful comment

This is probably a bad default name, we should replace the ~ with something else.

All 10 comments

This is probably a bad default name, we should replace the ~ with something else.

This is probably a bad default name, we should replace the ~ with something else.

Mm ok, just found it here if there is anyone with the same situation.

I assume that without ejecting, I can do nothing here?

If your app isn't embedded in a larger app, you shouldn't need this file for your app to function. Just delete it. 馃槃

You shouldn't need this file for your app to function. Just delete it. 馃槃

I would have to delete all the references from the build folder.
At this moment I receive mixes content (http(s)) and the serviceWorker is not up...

I think we should replace it with - instead of ~.

@Timer we are embedded 馃槩

Having the same issue. Who came up with putting ~ in the file name 馃槷

Filenames should only contain 1 and 0 馃槢

+1 for changing the ~ to something else. . -_ would all be better options.

This is not something we're doing in our webpack config. These are the default names that webpack uses for chunks. I'm not sure that we can easily change them. You might want to file an issue with webpack and then link to it here.

This is not something we're doing in our webpack config. These are the default names that webpack uses for chunks. I'm not sure that we can easily change them. You might want to file an issue with webpack and then link to it here.

I've attached links to files where the problem is in the webpack configuration

My company has a firewall rule that rejects any url with ~ in it. I need this fix (would not want to eject) for this issue.

Per Webpack #runtimeChunk documentation the config change is easily done as noted by op.

PR provided https://github.com/facebook/create-react-app/pull/7679

If this fix is already provided elsewhere I will gladly close.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaveLindberg picture DaveLindberg  路  3Comments

stopachka picture stopachka  路  3Comments

alleroux picture alleroux  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments

JimmyLv picture JimmyLv  路  3Comments