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

Migrate all static assets to vite entry point bundles and remove legacy asset handling "compress_assets" #23043

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

KevinMind
Copy link
Contributor

@KevinMind KevinMind commented Feb 3, 2025

Fixes: mozilla/addons#2000

Description

  • migrate all existing MINIFY_BUNDLES entrypoints to vite entrypoints
  • create missing bundles for admin defined entrypoints
  • small refactorings to make js/css code compatible with vite
  • add eslint and knip to force good habbits in js/css (remove dead code, no implicit globals, no undefined, etc)
  • add missing npm dependencies that were statically injected from source
  • add npm commands for all npm related test/lint/build scenarios
  • remove django_node_assets from dependencies
  • update static-files docs
  • remove static_assets pytest group as we can run all asset tests from source

Context

Follow up to #22957 migrating the remaining static files to use vite as a bundler.

Testing

  • Verify static assets are mapped correctly from the vite manifest (via make check)

Dev Mode

Fresh environment

make down && rm .env

Clean up existing static file artifacts

git clean -xfd static
rm -rf site-static/* static-build/*

Now run the app

make up

Expect:

  • all static asset files include the "X-served-by" vite except for static files served by olympia from 3rd party packages
  • all static assets resolve 200 from the vite server, no missing or miss routed files
  • modifying a file that is served on the current page will hotreload the page

Prod mode

Important

Assumed you already ran the dev mode checks to clear pre-existing static assets

Run the app in prod mode

make down && make up DOCKER_TARGET=production

Expect:

  • All static assets are served by nginx
  • Running make check verifies the assets in vite manifest are resolvable in the site-static directory
  • Site static directory should include vite assets bundle and the manifest
  • All static files resolve to their production url including a build hash
  • Static files are minified with source maps

Note

If DEBUG=True on prod mode, then expect non-minified files

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@KevinMind KevinMind force-pushed the kevinmind/addons/2000-migrate-files branch 4 times, most recently from 172c200 to 0a2dafb Compare February 3, 2025 11:00
@KevinMind KevinMind force-pushed the kevinmind/addons/2000-migrate-files branch from 0a2dafb to 7ef3c02 Compare February 11, 2025 11:27
@KevinMind KevinMind force-pushed the kevinmind/addons/2000-migrate-files branch from f10401e to fd12985 Compare February 11, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run compress_assets without management command (faster, faster)
1 participant