npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-vue-chrome-extension

v1.0.1

Published

A vite plugin for chrome-extension

Downloads

2

Readme

vite-plugin-vue-chrome-extension

一个 vite 插件,用于辅助 vite + vue 开发 chrome extension.

Install

npm i -D vite-plugin-vue-chrome-extension
yarn add -D vite-plugin-vue-chrome-extension
pnpm add -D vite-plugin-vue-chrome-extension

Usage

vite-plugin-vue-chrome-extension放到@vitejs/plugin-vue后面。

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import chromeVue from "vite-plugin-chrome-extension-vue";

export default defineConfig({
  plugins: [vue(), chromeVue()],
});

Options

options 没有,使用到vite.config.js的两个配置。

  • outDir 打包的文件路径默认还是dist,想改这个在vite.config.js中修改。
  • cacheDir 开发时文件缓存路径默认还是node_modules/.vite,想改这个在vite.config.js中修改。

Serve

开发时,文件被缓存到node_modules/.vite目录下,同时会拷贝项目根目录下的manifest.json文件到.vite/manifest.json,使用谷歌浏览器加载已解压扩展程序并选择.vite文件夹就可以打开。

manifest.json中的 popup 使用的index.html会被当作项目的入口文件,当然这个文件的路径中和名称都是可以修改的。一般使用vite + vue创建的index.html就可以了。

server_worker.js也就是 background.js 会被自动拷贝到.vite下。

多入口文件需要指定写在src/pages中以每个 page 中的index.html为入口文件。

  1. 项目文件目录结构
└── public
    │
    src
    ├── assets
    ├── components
    ├── pages
    │    ├── pageA
    │    │   ├── App.vue
    │    │   ├── index.html
    │    │   ├── main.ts
    │    └── pageB
    │        ├── App.vue
    │        ├── index.html
    │        └── main.ts
    ├── App.vue
    ├── main.js
    ├── server_worker.js
    │
    index.html
    │
    manifest.json
    │
    vite.config.js
  1. manifest.json 文件内容
{
  "manifest_version": 3,
  "name": "chrome test by vite",
  "version": "1.0.0",
  "description": "chrome test by vite",
  "background": {
    "service_worker": "src/service-worker.js",
    "type": "module"
  },
  "action": {
    "default_popup": "index.html",
    "default_icon": {
      "16": "src/assets/icons/logo.png",
      "32": "src/assets/icons/logo.png",
      "36": "src/assets/icons/logo.png",
      "48": "src/assets/icons/logo.png",
      "128": "src/assets/icons/logo.png"
    }
  },
  "permissions": ["tabs", "storage"],
  "host_permissions": ["<all_urls>"]
}

其中default_popup也可以写成src/pages/popup/index.html,不使用项目根目录下的index.html也是可以的。service_worker的路径也是可以修改。

Build

打包项目时,会根据manifest.json中的default_popup当作入口文件打包,同时还会看项目中的src有没有pages其他入口。文件会被打包到项目根目录下的dist. 使用谷歌浏览器加载已解压扩展程序并选择dist文件夹就可以打开。