chrome插件:一个基于webpack + react的chrome 插件项目模板

项目结构

bash 复制代码
$ tree -L 1
.
├── README.md
├── node_modules             # npm依赖
├── package.json             # 详细依赖
├── pnpm-lock.yaml 
├── public                   # 里边包含dist,安装的时候安装这个目录即可
├── src                      # 源码文件
└── webpack.config.js        # webpack打包配置 

主要的文件

manifest.json

bash 复制代码
{
  "name": "GoodDev",
  "manifest_version": 2,
  "version": "0.0.1",
  "description": "前端开发元素快速定位的chrome插件",

  "browser_action": {
    "default_icon": "icon.png",
    "default_title": "GoodDev",
    "default_popup": "dist/popup/popup.html"
  },

  "options_page": "dist/options/options.html",

  "permissions": ["tabs", "activeTab", "storage"],

  "background": {
    "scripts": [
	    "libs/webextension-polyfill.min.js", 
	    "dist/background/background.js"
    ]
  },

  "content_scripts": [
    {
      "matches": ["http://*/*", "https://*/*"],
      "run_at": "document_idle",
      "js": [
        "libs/jquery/jquery.min.js",
        "libs/webextension-polyfill.min.js",
        "dist/content/content.js"
      ]
    }
  ],
  "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}

package.json

json 复制代码
{
  "name": "good-dev",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "webpack watch --mode production",
    "build": "webpack --mode production"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "antd": "^5.8.6",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.22.15",
    "@babel/preset-react": "^7.22.15",
    "babel-loader": "^9.1.3",
    "copy-webpack-plugin": "^11.0.0",
    "css-loader": "^6.8.1",
    "style-loader": "^3.3.3",
    "webextension-polyfill": "^0.10.0",
    "webpack": "^5.88.2",
    "webpack-cli": "^5.1.4",
    "webpack-dev-server": "^4.15.1"
  }
}

完整项目结构

bash 复制代码
$ tree -I node_modules/
.
├── README.md
├── package.json
├── pnpm-lock.yaml
├── public
│   ├── icon.png
│   ├── index.html
│   ├── libs
│   │   ├── antd
│   │   │   ├── antd.min.js
│   │   │   └── reset.min.css
│   │   ├── dayjs
│   │   │   └── dayjs.min.js
│   │   ├── jquery
│   │   │   └── jquery.min.js
│   │   ├── react
│   │   │   ├── react-dom.production.min.js
│   │   │   └── react.production.min.js
│   │   └── webextension-polyfill.min.js
│   └── manifest.json
├── src
│   ├── background
│   │   └── background.js
│   ├── consts.js
│   ├── content
│   │   └── content.js
│   ├── options
│   │   ├── options.css
│   │   ├── options.html
│   │   └── options.js
│   ├── popup
│   │   ├── popup.css
│   │   ├── popup.html
│   │   └── popup.js
│   └── utils
│       ├── chrome-util.js
│       ├── copy-util.js
│       ├── dom-util.js
│       └── uuid-util.js
└── webpack.config.js

完整代码:https://github.com/mouday/good-dev/

相关推荐
afumu13 小时前
把五个网页版 AI 拉进同一个群聊:不用 API key 的多 Agent 编排
人工智能·chrome·typescript
用户298698530142 天前
React 前端将 Excel 工作表导出为图片的技术实践
javascript·react.js·excel
其实防守也摸鱼2 天前
个人学习 Pwn 思路:从基础到漏洞利用的进阶路径
大数据·前端·人工智能·chrome·算法·安全·网络安全
終不似少年遊*3 天前
【安全业务Agent】从场景到编排
python·react.js·ai·langchain·agent·安全架构·工作流
JavaPub-rodert3 天前
从零搭建通用管理后台:ShiyuAdmin 的 Go、React 与 RBAC 实践
开发语言·react.js·golang
李长渊哦4 天前
Qoder 自定义子智能体(Subagent)学习笔记
chrome·笔记·学习
Highcharts.js4 天前
React 中原生支持使用 JSX 组件配置自定义表格 Highcharts Grid
前端·javascript·react.js·前端框架·jsx·highcharts·自定义表格
JudithHuang4 天前
React 嵌套路由与布局
前端·react.js·arcgis·react·react router
前端小D4 天前
React Native项目开发(iOS侧为例)
javascript·react native·react.js
来让爷抱一个4 天前
Linux 磁盘 100% 但 du 查不出东西,五种情况逐个排
linux·网络·chrome