vue-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!
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
- 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>
- 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)
- 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
-
Clone the repository:
git clone https://github.com/Kocal/vue-web-extension.git cd vue-web-extension
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Build the extension for production:
npm run build
-
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 designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
vue-web-extension
: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:
- Everything you need to build a web extension (
manifest.json
,.zip
building, ...), thanks to adambullmer/vue-cli-plugin-browser-extension - Vue 2+
- Vue-router and Vuex
- Axios (configurable)
- Babel with preset-env
- ESLint and Prettier (both configurable)
Requirements
- Node.js >= 10 and npm >= 5
- git
- vue-cli 3+
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
Top Related Projects
⚡️ WebExtension Vite Starter Template
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot