Skip to content

Commit ae03b10

Browse files
authored
chore: remove vite integration code and use the canonicalwebteam.flask_vite package (#5444)
* chore: remove vite integration code and use the canonicalwebteam.flask_vite package - install canonicalwebteam.flask_vite - replace webapp.vite_integration with the new package - delete webapp.vite_integration package - update webapp.config with new VITE_REACT config parameter * fix: formatting * fix: doc comment for VITE_REACT variable * fix: add HACKING.md docs for Vite * fix: drive-by update stale docs
1 parent 3944084 commit ae03b10

15 files changed

Lines changed: 10 additions & 571 deletions

.github/copilot-instructions.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ webapp/ # Flask app (blueprints in */views.py)
5555
├── config.py # Env vars: SECRET_KEY, LOGIN_URL, VITE_PORT, ENVIRONMENT
5656
├── endpoints/ # API blueprints
5757
├── publisher/ # Publisher dashboard
58-
├── store/ # Store frontend
59-
└── vite_integration/ # Vite-Flask integration
58+
└── store/ # Store frontend
6059
static/js/ # React/TypeScript (Jotai state, React Router v7)
6160
├── publisher/ # Dashboard components
6261
├── public/ # Public-facing JS

HACKING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The application will be reporting errors to your `sentry.io` project from now on
7676

7777
## Testing
7878

79-
Install the [`dotrun`](https://snapcraft.io/dotrun) snap.
79+
Install [`dotrun`](https://github.com/canonical/dotrun), then run
8080

8181
``` bash
8282
dotrun test
@@ -98,3 +98,6 @@ We are supporting some custom licenses (like the Proprietary license). On update
9898
When the app is run locally, a GitHub personal access token is required to fetch the CVE data. Make sure you have access to the [canonicalwebteam.snap-cves](https://github.com/canonical/canonicalwebteam.snap-cves) repository. After creating a GitHub classic personal access token, follow the steps described in [GitHub's documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic).
9999
Then, add this token to the .env.local file with the key GITHUB_SNAPCRAFT_BOT_USER_TOKEN.
100100

101+
## Vite setup details
102+
This project relies on Vite for processing and bundling TypeScript and SCSS source files; referencing these files and the resulting bundles in templates is done through a `vite_import` template function provided by the [Canonical Webteam Flask-Vite integration](https://github.com/canonical/canonicalwebteam.flask-vite) package. The extension is configured via `VITE_*` variables that get loaded into the Flask `app.config` object where the extension reads them from.
103+
Files referenced via `vite_import` are automatically detected and added as entry points in the Vite config when running the build command.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# App dependencies
22
canonicalwebteam.flask-base==3.1.1
3+
canonicalwebteam.flask-vite==0.3.1
34
canonicalwebteam.candid==0.9.0
45
canonicalwebteam.discourse==7.0.0
56
canonicalwebteam.blog==6.6.0

tests/tests_vite_integration.py

Lines changed: 0 additions & 193 deletions
This file was deleted.

webapp/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class ConfigurationError(Exception):
2626
VITE_MODE = "development" if IS_DEVELOPMENT else "production"
2727
VITE_PORT = os.getenv("VITE_PORT", 5173)
2828
VITE_OUTDIR = os.getenv("VITE_OUTDIR", "static/js/dist/vite")
29+
# VITE_REACT controls whether React hot module reload scripts are injected when
30+
# running in dev mode; the setting has no effect in prod mode
31+
VITE_REACT = True
2932

3033
if ENVIRONMENT != "devel":
3134
SESSION_COOKIE_SAMESITE = "None"

webapp/extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from flask_wtf.csrf import CSRFProtect
2-
from webapp.vite_integration import FlaskVite
2+
from canonicalwebteam.flask_vite import FlaskVite
33

44
csrf = CSRFProtect()
55
vite = FlaskVite()

webapp/vite_integration/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

webapp/vite_integration/exceptions.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)