Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build files name change - files that are generated from create react app

The build files generated through create react app have different names(hash code) every time.

I would like to give a custom names for the generated files.

Is there any possibility to do the same?

like image 533
Arkantos1 Avatar asked Sep 25 '19 03:09

Arkantos1


People also ask

Can we rename create-react-app?

create-react-app appears to be a library on github, not a reversible command. Assuming it's an ordinary folder, you change the name of it the same way you would any other folder.


1 Answers

You can change the output filename by customizing the filename property in webpack config -- refer to https://webpack.js.org/guides/caching/

The default implementation is kept like this because, because every time you build an asset, it generates a new name and browsers won't be able to serve a cached response.

If you change the name to a constant you might need to clear the browser cache manually/ disable cache to see your changes immediately. (I think...Applicable only in prod mode as dev mode makes use of Hot module replacement)

Steps to change file name in CRA.

  1. npm run eject This will unwind the hidden configs from CRA and show some additional config folders

  2. Move to the config folder.

  3. Edit file webpack.config.js (Somewhere around line 172 - 180 you can see filename: section where this is defined)

like image 173
Nithin Thampi Avatar answered Nov 15 '22 08:11

Nithin Thampi