Skip to content

Commit 77fbe13

Browse files
author
djstein
committed
Update readme with directions and add utils
1 parent 266be5b commit 77fbe13

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1-
# webpack-django-build-tools
1+
# Webpack Django Build Tools
22
A set of postbuild tools for ensuring Webpack built JavaScript applications work seemlessly with Django
3+
4+
# 1 Update ```index.html``` With Static Tags
5+
6+
## 1.1 Summary
7+
To make use of Django and friends handling of static files with their unique hashes we need to replace hard links the JavaScript application bundle, maps, and other static files with their associated static template tag.
8+
9+
## 1.2 Implementation Steps
10+
### 1.2 Step 1: Copy ```static_tag.js``` to Project Directory
11+
From this GitHub directory clone and copy the util's folder into your project's root directory. An example project directory is below:
12+
```
13+
<app_name>
14+
├── README.md
15+
├── dist
16+
├── node_modules
17+
├── package-lock.json
18+
├── package.json
19+
├── src
20+
├── utils/
21+
├── static_tag.js
22+
├── webpack.config.babel.js
23+
└── yarn.lock
24+
```
25+
26+
### 1.2 Step 2: Update ```package.json```
27+
For this step in the ```package.json``` script section we will update the build line from:
28+
```
29+
"build": "webpack -p --progress"
30+
```
31+
to:
32+
```
33+
"build": "webpack -p --progress && node utils/static_tag.js <app_name>"
34+
```
35+
This will run a second command after the bundle build process that updates the ```index.html```.
36+
37+
### 1.2 Step 3: Run ```yarn build```
38+
Now when yarn build is run, the ```index.html``` will be updated and the JavaScript bundle and favicon path's will be updated with template tags that the Django or Jinja2 template language can read.

utils/static_tag.js

Whitespace-only changes.

0 commit comments

Comments
 (0)