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.

how to avoid '.next/static/commons/main-xxxx.js' change???

See original GitHub issue

next: 6.0.1-canary.2 just change a little code in page, the yarn build .next/static/commons/main-xxxx.js always change. How to avoid it? like this, modify some text in page/page2.js:

<div>Welcome to Page2 </div> to <div>Welcome to Page2 ABC </div>

the .next/static/commons/main-xxxx.js should not change when yarn build but the main-6974e8617b50c9d0b1bf.js changed to main-515736f6b9f5ff2e32e1.js

Does anyone know how to keep generated main-xxxx.js not change when dependent library has no change?

I already try to rewrite the next.config.js only process node_modules file, but no luck:

const path = require('path')

module.exports = {
  webpack: (config, { buildId, dev, isServer, defaultLoaders }) => {
    for (plugin of config.plugins) {
      if (plugin['constructor']['name'] === 'CommonsChunkPlugin') {
        plugin.minChunks = function (module, count) {
          var needChunk = (
            module.resource &&
            /\.js$/.test(module.resource) &&
            module.resource.indexOf(
              path.join(__dirname, './node_modules')
            ) === 0
          )
          if (needChunk) {
            console.log("needChunk = ", module.resource)
          }
          return needChunk
        }
        break;
      }
    }
    return config
  },
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
BosenYcommented, Aug 7, 2018

I wanna get like this .next/static/commons/main.js instead of .next/static/commons/main-xxxx.js how to operate ?

1reaction
timneutkenscommented, Sep 20, 2018

This won’t work with Next.js 7, and Next.js 7 implements records.json so hashes should be more stable now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
next: 6.0.1-canary.2 just change a little code in page, the yarn build .next/static/commons/main-xxxx.js always change. How to avoid it?
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