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
* Breaking changes:
Instead of defining a BASE_URL, webpack loader now expects BUNDLE_DIR_NAME.
`BUNDLE_DIR_NAME` refers to the directory that is added to STATICFILES_DIRS and contains the webpack output directory.
Copy file name to clipboardExpand all lines: README.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Read http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a detailed s
9
9
10
10
<br>
11
11
12
-
Use webpack to generate your static bundles without django's staticfiles or opaque wrappers.
12
+
Use webpack to generate your static bundles without django's staticfiles or opaque wrappers.
13
13
14
14
15
15
Django webpack loader consumes the output generated by [webpack-bundle-tracker](https://github.com/owais/webpack-bundle-tracker) and lets you use the generated bundles in django.
Assuming `assets/` is in `settings.STATICFILES_DIRS` like
44
+
45
+
STATIC_ASSETS = os.path.join(BASE_DIR, 'assets')
44
46
```python
45
47
STATICFILES_DIRS= (
46
-
os.path.join(BASE_DIR, 'assets'),
48
+
STATIC_ASSETS,
47
49
)
48
50
```
49
51
@@ -71,7 +73,7 @@ module.exports = {
71
73
### Default Configuration
72
74
```python
73
75
WEBPACK_LOADER= {
74
-
'BASE_URL':'webpack_bundles/',
76
+
'BUNDLE_DIR_NAME':'webpack_bundles/', # must end with slash
75
77
'STATS_FILE':'webpack-stats.json',
76
78
'POLL_DELAY':0.2,
77
79
'IGNORE': ['.+\.hot-update.js', '.+\.map']
@@ -80,19 +82,19 @@ WEBPACK_LOADER = {
80
82
81
83
<br>
82
84
83
-
#### WEBPACK_BUNDLE_URL
85
+
#### BUNDLE_DIR_NAME
84
86
```python
85
87
WEBPACK_LOADER= {
86
-
'BASE_URL':STATIC_URL+'bundles/'
88
+
'BUNDLE_DIR_NAME':'bundles/' # end with slash
87
89
}
88
90
```
89
91
90
-
`BASE_URL` is used to build the complete public url to the bundle that is used in `<script>` or `<link>` tags.
92
+
`BUNDLE_DIR_NAME` refers to the dir in which webpack outputs the bundles. It should not be the full path. If `./assets` it one of you static dirs and webpack generates the bundles in `./assets/output/bundles/`, then `BUNDLE_DIR_NAME` should be `output/bundles/`.
91
93
92
-
If the bundle generates a file called `main-cf4b5fab6e00a404e0c7.js`, then with the above config, the `<script>` tag will look like this
94
+
If the bundle generates a file called `main-cf4b5fab6e00a404e0c7.js` and your STATIC_URL is `/static/`, then the `<script>` tag will look like this
0 commit comments