-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35005 from dimagi/bmb/webpack
Building Webpack on HQ
- Loading branch information
Showing
38 changed files
with
2,283 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
corehq/apps/hqwebapp/management/commands/generate_webpack_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
|
||
import corehq | ||
|
||
WEBPACK_BUILD_DIR = Path(corehq.__file__).resolve().parent.parent / "webpack" / "_build" | ||
|
||
|
||
class Command(BaseCommand): | ||
help = ("Generates a settings file for webpack so that the same staticfiles directory " | ||
"that Django is using is passed to the Webpack build.") | ||
|
||
def handle(self, **options): | ||
webpack_settings = { | ||
'staticfilesPath': settings.STATIC_ROOT, | ||
} | ||
WEBPACK_BUILD_DIR.mkdir(parents=True, exist_ok=True) | ||
with open(WEBPACK_BUILD_DIR / "settings.json", "w") as f: | ||
json.dump(webpack_settings, f) |
11 changes: 11 additions & 0 deletions
11
corehq/apps/hqwebapp/static/hqwebapp/js/bootstrap3/commcarehq.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Core requirements for Bootstrap 3 Webpack Entry Modules | ||
import ko from 'knockout'; | ||
import mapping from 'ko.mapping'; | ||
ko.mapping = mapping; | ||
|
||
import 'bootstrap'; | ||
|
||
import 'hqwebapp/js/django'; | ||
|
||
import 'hqwebapp/js/bootstrap3/common'; | ||
import 'hqwebapp/js/bootstrap3/base_main'; |
11 changes: 11 additions & 0 deletions
11
corehq/apps/hqwebapp/static/hqwebapp/js/bootstrap5/commcarehq.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Core requirements for Bootstrap 5 Webpack Entry Modules | ||
import ko from 'knockout'; | ||
import mapping from 'ko.mapping'; | ||
ko.mapping = mapping; | ||
|
||
import 'bootstrap5'; | ||
|
||
import 'hqwebapp/js/django'; | ||
|
||
import 'hqwebapp/js/bootstrap5/common'; | ||
import 'hqwebapp/js/bootstrap5/base_main'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
corehq/apps/hqwebapp/templates/hqwebapp/partials/webpack.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% load hq_shared_tags %} | ||
|
||
{% if webpack_main %} | ||
<script> | ||
window.USE_WEBPACK = {{ webpack_main|BOOL }}; | ||
console.log("Loaded webpack main module: {{ webpack_main }}"); | ||
</script> | ||
{% for bundle_path in webpack_main|webpack_bundles %} | ||
<script src="{% static bundle_path %}"></script> | ||
{% endfor %} | ||
{% endif %} |
Oops, something went wrong.