aklinker1 / vite-plugin-web-extension

Vite plugin for developing Chrome/Web Extensions
https://vite-plugin-web-extension.aklinker1.io/
MIT License
553 stars 48 forks source link

feat!: v2 rewrite #44

Closed aklinker1 closed 1 year ago

aklinker1 commented 1 year ago

This is a full restructure of the application's code. Better organized, more extensible, unit testable, etc. The main change is the build process:

Old Build Process

graph LR;
  subgraph Primary Vite Build
    A[Build Manifest & All Standalone CSS files & HTML pages]-->B
    subgraph Secondary Vite Builds
      B[Build sandbox HTML]-->C
      C[Build each background.scripts]-->D
      D[Build background.page]-->E
      E[Build background.service_worker]-->F
    end
    F[Build each content_script.js]-->G
  end
  G[Done]

New Build Process

graph LR;
  subgraph Primary Vite Build
    A[Prepare Manifest]-->K
    subgraph Secondary Vite Builds
      K[Build HTML pages]-->B
      B[Build sandbox HTML]-->C
      C[Build each background.scripts]-->D
      D[Build background.page]-->E
      E[Build background.service_worker]-->
      F[Build each content_script.js]-->J
    end
    J[Build each content_script.css]-->G
    G[Write Manifest]-->H
  end
  H[Done]

Essentially, I was combining unrelated inputs into a single vite build, but am no longer. This provides more flexibility around when each individual build can be executed, such as waiting to write the manifest until the other builds have finished so we can user their outputs as the paths in the final manifest.json.

Content script CSS files are now built individually, separate from the HTML files.

Breaking changes

Todo

Future work:

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
vite-plugin-web-extension-docs-v1 🔄 Building (Inspect) Dec 18, 2022 at 10:46PM (UTC)
vite-plugin-web-extension-docs-v2 🔄 Building (Inspect) Dec 18, 2022 at 10:46PM (UTC)
aklinker1 commented 1 year ago

v2.0.0-apha1 has been released, feature complete minus HMR

aklinker1 commented 1 year ago

Alright, after alpha4, the plugin is working on my own extensions, I use watch mode for development. I need add back HMR and we'll be good to go!

aklinker1 commented 1 year ago

I've published 2.0.0-rc1 to the next tag and updated the documentation. I'll be trying it out in my extensions over the next few days.

aklinker1 commented 1 year ago

RC2 is out with the new web-ext config loading changes

aklinker1 commented 1 year ago

Alright, I've tested 2.0.0-rc10 on two of my personal extensions, and it is working! PR checks are all passing.

I'm gonna merge this and officially release v2.

kondr1 commented 1 year ago

What shold i use instead libModeViteConfig? Can you add it im migrate v2 instructions?

update: i found it libModeViteConfig > scriptViteConfig

aklinker1 commented 1 year ago

Yup, I'll update the docs, I forgot to add that