7 months ago
Hello,
I'm having trouble disabling source map generation for my React application (created with create-react-app) deployed on Railway.
My goal is to prevent the src/ folder from being visible in the browser's developer tools on my production site.
I have already tried the following, without success:
Setting the GENERATE_SOURCEMAP=false environment variable in the Railway project settings.
Explicitly setting the build command in package.json to include the flag.
Creating a dedicated build script ("build:railway": "CI=false GENERATE_SOURCEMAP=false react-scripts build").
Configuring my railway.toml to use this specific script (buildCommand = "npm run build:railway").
Multiple redeploys and clearing all browser cache, service workers, and testing in incognito mode.
Despite all these configurations, the deployed site continues to serve the full source maps. This points to a possible issue with the build cache or CDN cache on the platform side.
Could you please investigate or advise if there's a way to force a full, clean build and cache invalidation for my deployment?
3 Replies
7 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 8 months ago
7 months ago
Are you confident that during build time GENERATE_SOURCEMAP is available ?
Because when you add a variable on railway, that variable is only passed during runtime and not during build time.
You need to explicitly tell railway to pass this variable during build time as well.
smolpaw
Are you confident that during build time GENERATE_SOURCEMAP is available ?Because when you add a variable on railway, that variable is only passed during runtime and not during build time.You need to explicitly tell railway to pass this variable during build time as well.
6 months ago
Sorry the late reply but how do I "explicitly tell railway to pass this variable during build time"?
rodolfoachadev
Sorry the late reply but how do I "explicitly tell railway to pass this variable during build time"?
6 months ago
Yes. The variables are not available during build time by default
If you are using Dockerfile then right before the build specify them as ARG VARIABLE_NAME
Not the value, just the name of the variable.