Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
'BUNDLES_URL': 'webpack_bundles/', # must end with slash
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
'POLL_INTERVAL': 0.1,
'TIMEOUT': None,
Expand All @@ -110,24 +110,24 @@ When `CACHE` is set to True, webpack-loader will read the stats file only once a

<br>

#### BUNDLE_DIR_NAME
#### BUNDLES_URL
```python
WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': 'bundles/' # end with slash
'BUNDLES_URL': 'bundles/' # end with slash
}
}
```

`BUNDLE_DIR_NAME` refers to the dir in which webpack outputs the bundles. It should not be the full path. If `./assets` is one of your static dirs and webpack generates the bundles in `./assets/output/bundles/`, then `BUNDLE_DIR_NAME` should be `output/bundles/`.
`BUNDLES_URL` refers to the dir in which webpack outputs the bundles and will be used as the url prefix for the static files. It should not be the full path. If `./assets` is one of your static dirs and webpack generates the bundles in `./assets/output/bundles/`, then `BUNDLES_URL` should be `output/bundles/`.

If the bundle generates a file called `main-cf4b5fab6e00a404e0c7.js` and your STATIC_URL is `/static/`, then the `<script>` tag will look like this

```html
<script type="text/javascript" src="/static/output/bundles/main-cf4b5fab6e00a404e0c7.js"/>
```
**NOTE:** If your webpack config outputs the bundles at the root of your `staticfiles` dir, then `BUNDLE_DIR_NAME` should be an empty string `''`, not `'/'`.
**NOTE:** If your webpack config outputs the bundles at the root of your `staticfiles` dir, then `BUNDLES_URL` should be an empty string `''`, not `'/'`.
<br>
Expand Down Expand Up @@ -194,7 +194,7 @@ class ExternalWebpackLoader(WebpackLoader):
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': False,
'BUNDLE_DIR_NAME': 'bundles/',
'BUNDLES_URL': 'bundles/',
'LOADER_CLASS': 'app.module.ExternalWebpackLoader',
# Custom config setting made available in WebpackLoader's self.config
'STATS_URL': 'https://www.test.com/path/to/stats/',
Expand Down Expand Up @@ -259,11 +259,11 @@ Version 2.0 and up of webpack loader also supports multiple webpack configuratio
```python
WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': 'bundles/',
'BUNDLES_URL': 'bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
},
'DASHBOARD': {
'BUNDLE_DIR_NAME': 'dashboard_bundles/',
'BUNDLES_URL': 'dashboard_bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-dashboard.json'),
}
}
Expand Down Expand Up @@ -370,7 +370,7 @@ module.exports = config;
```python
if not DEBUG:
WEBPACK_LOADER.update({
'BUNDLE_DIR_NAME': 'dist/',
'BUNDLES_URL': 'dist/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-prod.json')
})
```
Expand Down
4 changes: 2 additions & 2 deletions tests/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': False,
'BUNDLE_DIR_NAME': 'bundles/',
'BUNDLES_URL': 'bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),
},
'APP2': {
'CACHE': False,
'BUNDLE_DIR_NAME': 'bundles/',
'BUNDLES_URL': 'bundles/',
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-app2.json'),
}
}
Expand Down
2 changes: 1 addition & 1 deletion webpack_loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_chunk_url(self, chunk):
return public_path

relpath = '{0}{1}'.format(
self.config['BUNDLE_DIR_NAME'], chunk['name']
self.config['BUNDLES_URL'], chunk['name']
)
return staticfiles_storage.url(relpath)

Expand Down