Project Structure
The extension follows a standard Vite-based project layout:Key Directories
Reusable Vue composition functions for storage and UI utilities
Business logic and utility functions, including the fetch wrapper
Main new tab page component (
NewTab.vue) and HTML entry point (index.html)Build System
The extension uses Vite with several plugins for an optimized development experience.Vite Configuration
The build is configured invite.config.ts:15-70 with:
Vite Plugins
@vitejs/plugin-vue
@vitejs/plugin-vue
Enables Vue 3 single-file component support
unplugin-auto-import
unplugin-auto-import
Auto-imports Vue APIs (
ref, computed, watch) and the webextension-polyfill library. You don’t need to manually import these in your components.unplugin-vue-components
unplugin-vue-components
Automatically registers components from
src/components/. Components are available globally without explicit imports.unplugin-icons
unplugin-icons
On-demand icon imports from popular icon sets
unocss
unocss
Atomic CSS engine for utility-first styling
assets-rewrite (custom)
assets-rewrite (custom)
Rewrites asset paths to use relative URLs in the production build. This ensures assets load correctly in the extension environment.
Build Output
The build process outputs toextension/dist/ as configured in vite.config.ts:84:
Extension Manifest
The manifest is dynamically generated insrc/manifest.ts.
Manifest Configuration
Chrome URL Overrides
Thechrome_url_overrides field (line 16-18) replaces Chrome’s default new tab page:
dist/newtab/index.html instead of the default page.
Permissions
Required for
chrome.storage.local API access. The extension stores user preferences (background color, fonts) using this API.Grants access to the GitHub Gist URL that hosts the quotes JSON file
Vue 3 Setup
The extension uses Vue 3 with the Composition API and<script setup> syntax.
Component Structure
The main component (src/newtab/NewTab.vue:1-265) uses:
- Composition API: All logic is defined in
<script setup> - Auto-imports: Vue APIs like
ref,computed,onMountedare automatically available - TypeScript: Full type safety with interfaces and type annotations
Asset Handling
Assets are managed through Vite’s asset pipeline:- Icons: Stored in
src/assets/and referenced in the manifest - Fonts: Loaded dynamically from Google Fonts CDN based on user selection
- Relative Paths: The custom
assets-rewriteplugin converts absolute paths to relative paths for extension compatibility
The extension dynamically loads Google Fonts at runtime (NewTab.vue:54-61) rather than bundling them, reducing the extension size.