You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 16, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,21 +31,23 @@ INSTALLED_APPS = [
31
31
]
32
32
```
33
33
34
-
### 2. Create an `importmap.toml` file
34
+
### 2. Configuring an import map
35
35
36
-
This should live next to your `manage.py` file.
37
-
Here you'll add a list of "packages" you want to use.
36
+
You JavaScript dependencies are conveniently located in your`pyproject.toml` file.
38
37
39
-
The "name" can be anything, but should probably be the same as what it you would import from in typical bundling setups (i.e. `import React from "react"`).
40
-
41
-
The "source" will get passed on to the [jspm.org generator](https://jspm.org/docs/api#install), but is basically the `<npm package>@<version>` you want to use.
38
+
They are listed under `[tool.importmap.dependencies]` and you can add them there. The format is `name = "version"`,
39
+
similar to how you would add a dependency to your `package.json` file.
42
40
43
41
```toml
44
-
[[packages]]
45
-
name = "react"
46
-
source = "react@17.0.2"
42
+
# pyproject.toml
43
+
[tool.importmap.dependencies]
44
+
react = "17.0.2"
45
+
react-dom = "17.0.2"
47
46
```
48
47
48
+
[jspm.org generator](https://jspm.org/docs/api#install) is used lock and serve the dependencies,
49
+
but is basically just like installing them via `npm i <npm package>@<version>`.
50
+
49
51
### 3. Run `importmap_generate`
50
52
51
53
To resolve the import map, you'll need to run `python manage.py importmap_generate`.
0 commit comments