Convert Figma logo to code with AI

Kocal logovue-web-extension

🛠️ A Vue CLI 3+ preset (previously a Vue CLI 2 boilerplate) for quickly starting a web extension with Vue, Babel, ESLint and more!

1,575
167
1,575
15

Top Related Projects

⚡️ WebExtension Vite Starter Template

Quick Overview

Kocal/vue-web-extension is a boilerplate project for creating browser extensions using Vue.js. It provides a solid foundation for developers to build cross-browser extensions with modern web technologies, including Vue 3, TypeScript, and Vite.

Pros

  • Streamlines the process of creating browser extensions with Vue.js
  • Supports modern development tools and practices (Vue 3, TypeScript, Vite)
  • Includes hot-reloading for faster development
  • Provides a well-structured project template with sensible defaults

Cons

  • May have a learning curve for developers new to Vue.js or browser extension development
  • Limited customization options out-of-the-box (though the project can be modified)
  • Requires manual configuration for some advanced extension features
  • Documentation could be more comprehensive for complex use cases

Code Examples

  1. Creating a new component:
<!-- src/components/HelloWorld.vue -->
<template>
  <div>
    <h1>{{ msg }}</h1>
    <button @click="count++">Count is: {{ count }}</button>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

defineProps<{ msg: string }>()
const count = ref(0)
</script>
  1. Defining a content script:
// src/content-scripts/content-script.ts
import { createApp } from 'vue'
import App from './App.vue'

const mountPoint = document.createElement('div')
mountPoint.id = 'my-extension-root'
document.body.appendChild(mountPoint)

createApp(App).mount(mountPoint)
  1. Setting up a background script:
// src/background.ts
chrome.runtime.onInstalled.addListener(() => {
  console.log('Extension installed')
})

chrome.action.onClicked.addListener((tab) => {
  if (tab.id) {
    chrome.tabs.sendMessage(tab.id, { action: 'toggle' })
  }
})

Getting Started

  1. Clone the repository:

    git clone https://github.com/Kocal/vue-web-extension.git
    cd vue-web-extension
    
  2. Install dependencies:

    npm install
    
  3. Start the development server:

    npm run dev
    
  4. Build the extension for production:

    npm run build
    
  5. Load the dist folder as an unpacked extension in your browser to test.

Competitor Comparisons

⚡️ WebExtension Vite Starter Template

Pros of vitesse-webext

  • Uses Vite for faster development and building
  • Includes TypeScript support out of the box
  • Offers a more modern and feature-rich development setup

Cons of vitesse-webext

  • May have a steeper learning curve for beginners
  • Potentially more complex configuration due to additional features

Code Comparison

vue-web-extension:

// webpack.config.js
module.exports = {
  entry: { background: './background.js' },
  output: { filename: '[name].js' },
  // ...
}

vitesse-webext:

// vite.config.ts
export default defineConfig({
  build: {
    rollupOptions: {
      input: {
        background: resolve(__dirname, 'src/background/index.ts'),
        // ...
      },
    },
  },
  // ...
})

The code comparison shows the difference in build configuration between the two projects. vue-web-extension uses webpack, while vitesse-webext utilizes Vite's configuration format, demonstrating the shift towards more modern build tools.

vitesse-webext offers a more comprehensive and up-to-date development environment, leveraging Vite and TypeScript. However, it may be more challenging for newcomers to web extension development. vue-web-extension, while potentially simpler, might be better suited for those familiar with webpack-based setups or looking for a more straightforward starting point.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

vue-web-extension

Netlify Status

:warning: This README is for the master version of the preset. If you use the v1 of this boilerplate with Vue-CLI 2 support, please see v1 branch.


This Vue CLI preset allows you to quickly start a web extension containing:

Requirements

Documentation

The documentation can be found on vue-web-extension.netlify.app. Please check the documentation website and the open and closed issues, before raising a new issue.

Usage

$ vue create --preset kocal/vue-web-extension my-extension
$ cd my-extension
$ npm run build

npm run build

Build the extension into dist folder for production.

A zip file is also built and is located in artifacts directory.

npm run serve

Build the extension for development and watch over file changes.

It also automatically reload your extension into your browsers, thanks to webpack-extension-reloader plugin.

Options

See https://github.com/adambullmer/vue-cli-plugin-browser-extension#plugin-options

NPM DownloadsLast 30 Days