how to rename /_next/static/1498<RANDOM_ID>.js
Unanswered
Cuban Crocodile posted this in #help-forum
Cuban CrocodileOP
We are using the next app due to some CDN mess up some static files went as 0byte files and browser cached it on Users devices.. so we want to rename all the static paths.. Any way we can rename or change the ID attached to webpack-<random_id> with some different value ?
7 Replies
Cuban CrocodileOP
Cuban CrocodileOP
@Sun bear assert prefix we will add before prefix _next.. we are using CDN so we have replace the rule in CDN to accomadate this prefix.. so cant go for that
Sun bear
I am not sure how to change the output filename likely could be done with a custom webpack config in your next config.
But using an asset prefix would avoid having to jump through these hoops. The pattern I have adopted at my company is /assets/{application-name}/{git-sha}/filexyz.js
This allows for each deployment to not be in conflict with itself. And guarantees no conflicts with user cached assets
But using an asset prefix would avoid having to jump through these hoops. The pattern I have adopted at my company is /assets/{application-name}/{git-sha}/filexyz.js
This allows for each deployment to not be in conflict with itself. And guarantees no conflicts with user cached assets
Cuban CrocodileOP
@Sun bear tq for this.. how you achieved /assets/{application-name}/{git-sha}/filexyz.js pattern ?.. possible to share the config file for this?
Sun bear
There is nothing in the config. During the build you set the CDN_PREFIX and upload the data to the cdn. Then when runninng the instance you pass the same CDN_PREFIX
Cuban CrocodileOP
This is working to add build id
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.resolve.modules = [path.resolve(__dirname, 'node_modules'), 'node_modules'];
config.resolve.fallback = {
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
// by next.js will be dropped. Doesn't make much sense, but how it is
fs: false, // the solution
};
console.error('config.resolve.output', config.output);
config.output = {
...config.output,
filename:
chunkFilename:
};
return config;
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.resolve.modules = [path.resolve(__dirname, 'node_modules'), 'node_modules'];
config.resolve.fallback = {
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
// by next.js will be dropped. Doesn't make much sense, but how it is
fs: false, // the solution
};
console.error('config.resolve.output', config.output);
config.output = {
...config.output,
filename:
${config.output.filename}-revalidated-${buildId}.js,chunkFilename:
${config.output.chunkFilename}-revalidated-${buildId}.js,};
return config;
},