when custom generateBuildId and webpack output.filename, Cannot find module
See original GitHub issueBug report
Describe the bug
Each rebuild will generate a new buildId, the buildid is a directory, most files’ path will be changed when rebuilt.

not conducive to using browser cache
and if i use generateBuildId to custom buildid
generateBuildId: async () => {
// For example get the latest git commit hash here
return 'my-build-id'
}
i must custom webpack config to refresh file name
webpack(config, {buildId, dev, isServer, defaultLoaders}) {
...
config.output.filename = '[name].[hash:8].js';
...
}

but then,

Cannot find module 'somepath/ssr/server/static/xxx/pages/_app.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at hasCustomAppGetInitialProps (somepath/node_modules/next/dist/build/utils.js:25:1002)
because the output filename is _app.js.d80047c4.js
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
when custom generateBuildId and webpack output.filename ...
AssetPrefix works to control where I want to LOAD assets from, but I want to control where those generated css files get saved...
Read more >Output filename not configured Error in Webpack
I was getting the same error and it turned out to be my webpack config file name. I had it as " webpack.config...
Read more >Output - webpack
See output.filename option for details on the possible values. Note that these filenames ... Customize the names used in each source map's sources...
Read more >Caching - webpack
This guide focuses on the configuration needed to ensure files produced by webpack compilation can remain cached unless their content has changed. Output...
Read more >Development - webpack
This guide extends on code examples found in the Output Management guide. ... output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist'), ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

To answer the “why” for me: I use bootstrap, and import the .css files in _app.js. I serve my application under the /releases/buildId/ folder of an S3 bucket in AWS. This makes it super easy to test my new code. The CSS for bootstrap is attempting to load from domain.dev/_next/static/… this is not what I want. I want to control the output of this _next/static folder. What other ways can I do this?
AssetPrefix works to control where I want to LOAD assets from, but I want to control where those generated css files get saved to.
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.