opened
T-101
username_0
asset_manifest.py fails when CRA liveserver is not found.

```
File "/usr/local/lib/python3.7/site-packages/cra_helper/asset_manifest.py", line 50, in generate_manifest
_manifest[asset_key] = os.path.relpath(path, 'static/')
File "/usr/local/lib/python3.7/posixpath.py", line 459, in relpath
  path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not dict
```

I've pinpointed the cause here: [https://github.com/username_1/django-cra-helper/blob/e1c8165351ef5083328df8fe36fb062bc1e398ab/cra_helper/asset_manifest.py#L46](https://github.com/username_1/django-cra-helper/blob/e1c8165351ef5083328df8fe36fb062bc1e398ab/cra_helper/asset_manifest.py#L46)

The filemappings are under `files` key. Changing line 46 to:
`for filename, path in data.get('files').items():`
seems to fix the issue. I am guessing this is the desired functionability?
Asset loading error when CRA liveserver not found
issue
created
MasterKale
username_1
Aha! Create-React-App changed the format of the asset manifest! In the past the manifest was flat, like this:

```jsonc
{
  "static/js/0.3008f445.chunk.js": "/static/js/0.3008f445.chunk.js",
  "static/js/0.3008f445.chunk.js.map": "/static/js/0.3008f445.chunk.js.map",
  "static/js/1.185a9fcb.chunk.js": "/static/js/1.185a9fcb.chunk.js",
  "static/js/1.185a9fcb.chunk.js.map": "/static/js/1.185a9fcb.chunk.js.map",
  // ...snip...
}
```

Looking at the build output from a more recent Create-React-App project I'm working on, though, I see that they now nest these links under a `files` property:

```jsonc
{
  "files": {
    "static/js/0.3008f445.chunk.js": "/static/js/0.3008f445.chunk.js",
    "static/js/0.3008f445.chunk.js.map": "/static/js/0.3008f445.chunk.js.map",
    "static/js/1.185a9fcb.chunk.js": "/static/js/1.185a9fcb.chunk.js",
    "static/js/1.185a9fcb.chunk.js.map": "/static/js/1.185a9fcb.chunk.js.map",
    // ...snip...
  }
}
```

Your fix is indeed along the lines of how this'll get fixed here. It'll be a little tricky to update it with backwards compatibility for the old format, but it should be possible.
comment
created
10686142
username_2
Any estimation when the fix will be available?
comment
created
MasterKale
username_1
@username_0 and @username_2: Can I bother you to confirm which version of `react-scripts` you're using? I've discovered three different versions of manifests depending on the version of `react-scripts` being used:

v2.8.0 manifest:
```json
{
  "main.css": "/static/css/main.80e572c9.chunk.css",
  "main.js": "/static/js/main.ef0788cc.chunk.js",
  "main.js.map": "/static/js/main.ef0788cc.chunk.js.map",
  "runtime~main.js": "/static/js/runtime~main.a8a9905a.js",
  "runtime~main.js.map": "/static/js/runtime~main.a8a9905a.js.map",
  "static/js/2.597565cd.chunk.js": "/static/js/2.597565cd.chunk.js",
  "static/js/2.597565cd.chunk.js.map": "/static/js/2.597565cd.chunk.js.map",
  "index.html": "/index.html",
  "precache-manifest.06aece505f403b62363ab3795d4669de.js": "/precache-manifest.06aece505f403b62363ab3795d4669de.js",
  "service-worker.js": "/service-worker.js",
  "static/css/main.80e572c9.chunk.css.map": "/static/css/main.80e572c9.chunk.css.map",
  "static/media/logo.svg": "/static/media/logo.25bf045c.svg"
}
```

v3.1.2 manifest:
```json
{
  "files": {
    "main.css": "/static/css/main.b100e6da.chunk.css",
    "main.js": "/static/js/main.5745ba44.chunk.js",
    "main.js.map": "/static/js/main.5745ba44.chunk.js.map",
    "runtime-main.js": "/static/js/runtime-main.e5179790.js",
    "runtime-main.js.map": "/static/js/runtime-main.e5179790.js.map",
    "static/js/2.24ceb05b.chunk.js": "/static/js/2.24ceb05b.chunk.js",
    "static/js/2.24ceb05b.chunk.js.map": "/static/js/2.24ceb05b.chunk.js.map",
    "index.html": "/index.html",
    "precache-manifest.ed3a557b9335d6efb0f3f61d4c8baa40.js": "/precache-manifest.ed3a557b9335d6efb0f3f61d4c8baa40.js",
    "service-worker.js": "/service-worker.js",
    "static/css/main.b100e6da.chunk.css.map": "/static/css/main.b100e6da.chunk.css.map",
    "static/media/logo.svg": "/static/media/logo.25bf045c.svg"
  }
}
```

v3.2.0 manifest:
```json
{
  "files": {
    "main.css": "/static/css/main.b100e6da.chunk.css",
    "main.js": "/static/js/main.f245946a.chunk.js",
    "main.js.map": "/static/js/main.f245946a.chunk.js.map",
    "runtime-main.js": "/static/js/runtime-main.7b0131e1.js",
    "runtime-main.js.map": "/static/js/runtime-main.7b0131e1.js.map",
    "static/js/2.7059510f.chunk.js": "/static/js/2.7059510f.chunk.js",
    "static/js/2.7059510f.chunk.js.map": "/static/js/2.7059510f.chunk.js.map",
    "index.html": "/index.html",
    "precache-manifest.68f3de19261ab9bb69c0c6a58c46215e.js": "/precache-manifest.68f3de19261ab9bb69c0c6a58c46215e.js",
    "service-worker.js": "/service-worker.js",
    "static/css/main.b100e6da.chunk.css.map": "/static/css/main.b100e6da.chunk.css.map",
    "static/media/logo.svg": "/static/media/logo.25bf045c.svg"
  },
  "entrypoints": [
    "static/js/runtime-main.7b0131e1.js",
    "static/js/2.7059510f.chunk.js",
    "static/css/main.b100e6da.chunk.css",
    "static/js/main.f245946a.chunk.js"
  ]
}
```

This issue and issue #3 both sound like v3.1.2, especially since v3.2.0 only dropped a week ago.
comment
created
T-101
username_0
When this issue arose, that project was on 3.1.1.
I also started another project which has the new 3.2.0.
comment
created
MasterKale
username_1
Boy oh boy, Create-React-App has grown in complexity since I first released this plugin. Thanks for getting me off my butt to give this project some TLC.

I've finished adding support for parsing all three of the above versions of **asset-manifest.json**, and it works great for loading files after a `npm run build` and then a `python ./manage.py collectstatic --no-input`.

I hit a speed bump with updating support for loading files from the CRA liveserver, though. More recent versions of the liveserver now inject "bundle.js", a new "main.chunk.js", and **alternate between injecting a "0.chunk.js" and "1.chunk.js" file every time you update a component and CRA hot-reloads http://localhost:3000**. 🤦‍♂ I think I've figured out a solution, though, so I'll keep you posted.
comment
closed
MasterKale
username_1
issue
created
MasterKale
username_1
I've released **django-cra-helper v1.2.0** that includes a fix for this. Give it a try!
comment