Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch frontend build process from Webpack to Vite #1725

Merged
merged 31 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4ff1894
Bootstrap Vue 2/Vite app with `npm create vue@legacy`
mvandenburgh Nov 6, 2023
37bdedc
Update favicon
mvandenburgh Nov 6, 2023
6e7882d
Update index.html
mvandenburgh Nov 6, 2023
3d8e5f4
Move src/ directory to vite app
mvandenburgh Nov 6, 2023
f7cb8dd
Copy .env files to vite/
mvandenburgh Nov 6, 2023
b7cfa80
Update env vars to vite syntax
mvandenburgh Nov 6, 2023
0477a8a
Update package.json, add yarn.lock
mvandenburgh Nov 6, 2023
e604125
Configure polyfills for Node.js APIs
mvandenburgh Nov 6, 2023
de3519c
Configure Vuetify 2 for Vite
mvandenburgh Nov 7, 2023
aabb058
Move other files to vite/ directory
mvandenburgh Nov 7, 2023
2aaa643
Move netlify redirectory to vite/
mvandenburgh Nov 7, 2023
6c88eac
Add editorconfig to vite/
mvandenburgh Nov 7, 2023
00660eb
Move E2E tests to vite/
mvandenburgh Nov 7, 2023
beda671
Rename vite/ to web/ and delete old web/ dir
mvandenburgh Nov 7, 2023
080f253
Run client dev server on port 8085
mvandenburgh Nov 7, 2023
1009a5d
Add git revision to vite config
mvandenburgh Nov 7, 2023
cacf3d5
Fix import error
mvandenburgh Nov 7, 2023
7d39a1d
Update static image serving to vite syntax
mvandenburgh Nov 7, 2023
637bbd8
Update frontend github action
mvandenburgh Nov 7, 2023
10fb630
Move e2e tests to root directory
mvandenburgh Nov 7, 2023
2a9070a
Use node 20 for netlify build
mvandenburgh Nov 17, 2023
38eaba9
Update redirector env vars to VITE syntax
mvandenburgh Nov 17, 2023
b15c9f9
Bring in TS config from previous webpack config
mvandenburgh Dec 1, 2023
2c3aced
Switch to vite types
mvandenburgh Dec 1, 2023
84fb0fb
Relax linting rule
mvandenburgh Dec 1, 2023
1a1faf3
Install `eslint-plugin-import`
mvandenburgh Dec 1, 2023
54f1e03
Remove empty boilerplate file
mvandenburgh Dec 6, 2023
6998caa
Add autogenerated plugin types to gitignore
mvandenburgh Dec 6, 2023
efb8276
Add linting rules from old config
mvandenburgh Dec 7, 2023
05f413f
Restore vuetify eslint plugin config
mvandenburgh Dec 7, 2023
e870965
Format `.eslintrc.cjs`
mvandenburgh Dec 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: yarn run lint --no-fix

- name: Type-check Vue app
run: yarn run type
run: yarn run type-check

- name: Build Vue app
run: yarn run build
Expand Down Expand Up @@ -70,9 +70,9 @@ jobs:
DANDI_ALLOW_LOCALHOST_URLS: 1

# Web client env vars
VUE_APP_DANDI_API_ROOT: http://localhost:8000/api/
VUE_APP_OAUTH_API_ROOT: http://localhost:8000/oauth/
VUE_APP_OAUTH_CLIENT_ID: Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl
VITE_APP_DANDI_API_ROOT: http://localhost:8000/api/
VITE_APP_OAUTH_API_ROOT: http://localhost:8000/oauth/
VITE_APP_OAUTH_CLIENT_ID: Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl

# E2E tests env vars
CLIENT_URL: http://localhost:8085
Expand All @@ -82,7 +82,6 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: web/yarn.lock

Expand Down Expand Up @@ -116,23 +115,23 @@ jobs:

- name: Install E2E tests
run: yarn install --frozen-lockfile
working-directory: web/test
working-directory: e2e

- name: Lint E2E tests
run: yarn run lint --no-fix --max-warnings=0
working-directory: web/test
working-directory: e2e

- name: Run E2E tests
run: |
# start vue dev server and wait for it to start
yarn --cwd .. run serve 2> /dev/null &
yarn --cwd ../web/ run dev 2> /dev/null &
while ! nc -z localhost 8085; do
sleep 3
done

# start the dandi-api server
python ../../manage.py runserver &
python ../manage.py runserver &

# run the E2E tests
yarn run test
working-directory: web/test
working-directory: e2e
2 changes: 1 addition & 1 deletion doc/design/apex-domain-netlify.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Currently, the GUI is served at gui.dandiarchive.org, while the apex domain dand
We've decided that our UI is stable enough to warrant serving it directly at dandiarchive.org, leaving just the task of serving a JSON file containing deployment information. Netlify seems capable of performing this task, and this document outlines the proposal to do so.

## Serving the Deployment JSON file
Netlify cannot specify a different set of redirects for a different build context, so a custom plugin is required. Netlify does support custom JS plugins that hook into the build process and modify the Netlify configuration, so we can use that to specify a different redirect based on the `VUE_APP_DANDI_API_ROOT` environment variable. This redirect will proxy `dandiarchive.org/server-info` to `api.dandiarchive/api/server-info`, or the appropriate domains for staging.
Netlify cannot specify a different set of redirects for a different build context, so a custom plugin is required. Netlify does support custom JS plugins that hook into the build process and modify the Netlify configuration, so we can use that to specify a different redirect based on the `VITE_APP_DANDI_API_ROOT` environment variable. This redirect will proxy `dandiarchive.org/server-info` to `api.dandiarchive/api/server-info`, or the appropriate domains for staging.

## Backwards Compatibility

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions web/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VUE_APP_DANDI_API_ROOT=http://localhost:8000/api/
VUE_APP_OAUTH_API_ROOT=http://localhost:8000/oauth/
VUE_APP_OAUTH_CLIENT_ID=Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl
VITE_APP_DANDI_API_ROOT=http://localhost:8000/api/
VITE_APP_OAUTH_API_ROOT=http://localhost:8000/oauth/
VITE_APP_OAUTH_CLIENT_ID=Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl
10 changes: 5 additions & 5 deletions web/.env.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VUE_APP_OAUTH_API_ROOT="https://api.dandiarchive.org/oauth/"
VUE_APP_OAUTH_CLIENT_ID="Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VUE_APP_DANDI_API_ROOT="https://api.dandiarchive.org/api/"
VUE_APP_SENTRY_DSN="https://[email protected]/5196549"
VUE_APP_SENTRY_ENVIRONMENT="production"
VITE_APP_OAUTH_API_ROOT="https://api.dandiarchive.org/oauth/"
VITE_APP_OAUTH_CLIENT_ID="Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VITE_APP_DANDI_API_ROOT="https://api.dandiarchive.org/api/"
VITE_APP_SENTRY_DSN="https://[email protected]/5196549"
VITE_APP_SENTRY_ENVIRONMENT="production"
24 changes: 15 additions & 9 deletions web/.eslintrc.js → web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
root: true,
env: {
node: true,
},
plugins: [
'vuetify',
],
extends: [
'plugin:vue/essential',
'plugin:vuetify/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'eslint:recommended',
'plugin:vue/recommended',
'@vue/airbnb',
'@vue/typescript',
'@vue/eslint-config-typescript',
],
rules: {
camelcase: 'off',
Expand All @@ -37,7 +39,11 @@ module.exports = {
'import/prefer-default-export': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
},
parserOptions: {
parser: '@typescript-eslint/parser',
settings: {
'import/resolver': {
typescript: {
project: '.'
}
},
},
};
}
141 changes: 26 additions & 115 deletions web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,119 +1,30 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
# Logs
logs
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# pycharm
**/.idea

node_modules/
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Autogenerated file
components.d.ts
5 changes: 0 additions & 5 deletions web/babel.config.js

This file was deleted.

3 changes: 2 additions & 1 deletion web/public/index.html → web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="icon" href="/favicon.ico">
<title>DANDI Archive</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
Expand All @@ -14,6 +14,7 @@
<strong>We're sorry but the DANDI Archive doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<!-- built files will be auto injected -->
</body>
</html>
36 changes: 18 additions & 18 deletions web/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ command = "yarn run build"

# Staging
[context.master.environment]
NODE_VERSION = "16" # Netlify defaults to node.js 10, but @types/node requires a more recent version
VUE_APP_OAUTH_API_ROOT = "https://api-staging.dandiarchive.org/oauth/"
VUE_APP_OAUTH_CLIENT_ID = "Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VUE_APP_DANDI_API_ROOT = "https://api-staging.dandiarchive.org/api/"
VUE_APP_SENTRY_DSN = "https://[email protected]/5196549"
VUE_APP_SENTRY_ENVIRONMENT = "staging"
NODE_VERSION = "20"
VITE_APP_OAUTH_API_ROOT = "https://api-staging.dandiarchive.org/oauth/"
VITE_APP_OAUTH_CLIENT_ID = "Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VITE_APP_DANDI_API_ROOT = "https://api-staging.dandiarchive.org/api/"
VITE_APP_SENTRY_DSN = "https://[email protected]/5196549"
VITE_APP_SENTRY_ENVIRONMENT = "staging"

# Deploy previews
[context.deploy-preview.environment]
NODE_VERSION = "16" # Netlify defaults to node.js 10, but @types/node requires a more recent version
VUE_APP_OAUTH_API_ROOT = "https://api-staging.dandiarchive.org/oauth/"
VUE_APP_OAUTH_CLIENT_ID = "Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VUE_APP_DANDI_API_ROOT = "https://api-staging.dandiarchive.org/api/"
VUE_APP_SENTRY_DSN = "https://[email protected]/5196549"
VUE_APP_SENTRY_ENVIRONMENT = "staging"
NODE_VERSION = "20"
VITE_APP_OAUTH_API_ROOT = "https://api-staging.dandiarchive.org/oauth/"
VITE_APP_OAUTH_CLIENT_ID = "Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VITE_APP_DANDI_API_ROOT = "https://api-staging.dandiarchive.org/api/"
VITE_APP_SENTRY_DSN = "https://[email protected]/5196549"
VITE_APP_SENTRY_ENVIRONMENT = "staging"

# Production
[context.release.environment]
NODE_VERSION = "16" # Netlify defaults to node.js 10, but @types/node requires a more recent version
VUE_APP_OAUTH_API_ROOT = "https://api.dandiarchive.org/oauth/"
VUE_APP_OAUTH_CLIENT_ID = "Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VUE_APP_DANDI_API_ROOT = "https://api.dandiarchive.org/api/"
VUE_APP_SENTRY_DSN = "https://[email protected]/5196549"
VUE_APP_SENTRY_ENVIRONMENT = "production"
NODE_VERSION = "20"
VITE_APP_OAUTH_API_ROOT = "https://api.dandiarchive.org/oauth/"
VITE_APP_OAUTH_CLIENT_ID = "Dk0zosgt1GAAKfN8LT4STJmLJXwMDPbYWYzfNtAl"
VITE_APP_DANDI_API_ROOT = "https://api.dandiarchive.org/api/"
VITE_APP_SENTRY_DSN = "https://[email protected]/5196549"
VITE_APP_SENTRY_ENVIRONMENT = "production"


[[redirects]]
Expand Down
4 changes: 2 additions & 2 deletions web/netlify/plugins/server-info-build/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
// Use onPostBuild hook so that the dist/ folder exists
onPostBuild: ({ netlifyConfig }) => {
let apiUrl = process.env.VUE_APP_DANDI_API_ROOT;
let apiUrl = process.env.VITE_APP_DANDI_API_ROOT;
if (apiUrl === undefined) {
throw new Error('API URL not defined. Please define it with the VUE_APP_DANDI_API_ROOT environment variable.');
throw new Error('API URL not defined. Please define it with the VITE_APP_DANDI_API_ROOT environment variable.');
}

// Add redirect to server info
Expand Down
Loading