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.

Static keys for vendor bundle in asset-manifest.json

See original GitHub issue

Currently the asset-manifest.json in my build folder looks like this:

{
  "main.css": "/static/css/main.f4f38731.chunk.css",
  "main.js": "/static/js/main.56255761.chunk.js",
  "main.js.map": "/static/js/main.56255761.chunk.js.map",
  "static/css/1.36ceda45.chunk.css": "/static/css/1.36ceda45.chunk.css",
  "static/js/1.ade53803.chunk.js": "/static/js/1.ade53803.chunk.js",
  "static/js/1.ade53803.chunk.js.map": "/static/js/1.ade53803.chunk.js.map",
  "runtime~main.js": "/static/js/runtime~main.229c360f.js",
  "runtime~main.js.map": "/static/js/runtime~main.229c360f.js.map",
  "static/media/icons.svg": "/static/media/icons.6e39cadf.svg",
  "static/media/logo.svg": "/static/media/logo.61c6330d.svg",
  "static/media/help_logo.svg": "/static/media/help_logo.1ef27f5c.svg",
  "static/media/help_logo_mark.svg": "/static/media/help_logo_mark.8265813a.svg",
  "static/media/youtube_icon.svg": "/static/media/youtube_icon.d435ea9a.svg",
  "static/media/guarantee_emblem.svg": "/static/media/guarantee_emblem.d49af9a1.svg",
  "static/css/main.f4f38731.chunk.css.map": "/static/css/main.f4f38731.chunk.css.map",
  "static/css/1.36ceda45.chunk.css.map": "/static/css/1.36ceda45.chunk.css.map",
  "index.html": "/index.html",
  "precache-manifest.be82c4ddabdcb9e12cd3d143baad1412.js": "/precache-manifest.be82c4ddabdcb9e12cd3d143baad1412.js",
  "service-worker.js": "/service-worker.js"
}

I want to be able to use this asset-manifest.json to reference and and include my own script tags. However, the vendor bundle has dynamic keys:

  "static/css/1.36ceda45.chunk.css": "/static/css/1.36ceda45.chunk.css",
  "static/js/1.ade53803.chunk.js": "/static/js/1.ade53803.chunk.js",
  "static/js/1.ade53803.chunk.js.map": "/static/js/1.ade53803.chunk.js.map",

Is it possible to make these references something like static/css/1.chunk.css instead?

Using react-scripts@2.0.3

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
jbachcommented, Oct 5, 2018

Considering the use case mentioned in https://github.com/facebook/create-react-app/issues/5172: Previously, I could just load the file referenced under the main.js key, thus not caring about changes.

It looks like loading an application now requires the runtime (runtime~main.js), the randomly named vendor chunk (static/js/1.ade53803.chunk.js) and the actual entry script (main.js).

How can a CRA-agnostic backend properly serve the application, if the vendor chunk is not statically keyed? Sorry, if this sounds like a dumb question.

6reactions
Zemeliacommented, Nov 29, 2018

Hello, have same issue. We have hashed keys due configs in webpack.config.prod.js, where name is ‘false’. splitChunks: { chunks: 'all', name: false, }, When I change this to true, I get normal names, so I can get vendors~main.js from asset-manifest.json 400x400-29_11_2018_150015

Can be used next workaround within https://www.npmjs.com/package/@craco/craco

// craco.config.js
module.exports = function({env}) {
  if (env === 'production') {
    return {
      plugins: [
        {
          plugin: {
            overrideWebpackConfig: ({ webpackConfig}) => {
              webpackConfig.optimization.splitChunks.name = true;
              return webpackConfig;
            },
          },
          options: {}
        }
      ]
    };
  }
  return {};
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 5 webpack-assets-manifest Code Examples - Snyk
Learn more about how to use webpack-assets-manifest, based on webpack-assets-manifest code examples created from the most popular ways it is used in public ......
Read more >
handling of static assets with webpack-manifest-plugin in a ...
Problem 1: In the manifest I only get the key of the new location but ... My second approach was to define a...
Read more >
The Build Series: E3 — Micro-Frontends are Awesome!
In this episode of The Build Series, We'll explore some Micro-Frontend design patterns for web applications and build one using React.
Read more >
Issues · facebook/create-react-app · GitHub
Static keys for vendor bundle in asset-manifest.json issue: proposal ... [ModuleScopePlugin] problem with nested package.json in linked dependencies issue: ...
Read more >
How to Deploy a React + Flask Project - miguelgrinberg.com
You can control this with the homepage field in your package.json. ... To achieve this we need to point Flask's static folder to...
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