question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when custom generateBuildId and webpack output.filename, Cannot find module

See original GitHub issue

Bug report

Describe the bug

Each rebuild will generate a new buildId, the buildid is a directory, most files’ path will be changed when rebuilt. image

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';
        ...
}

image

but then, image

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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
juneeighteencommented, Jun 15, 2020

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.

0reactions
balazsorban44commented, Jan 29, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found