@crxjs/vite-plugin 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +42 -21
  2. package/dist/index.mjs +30 -4
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,33 +1,54 @@
1
- > [!IMPORTANT]
2
- > CRXJS is seeking new maintainers. If no maintenance team is established by March 31, 2025, this repository will be archived. [Learn more](https://github.com/crxjs/chrome-extension-tools/discussions/974).
1
+ ![CRXJS](./banner-github.png)
3
2
 
4
- # ![CRXJS](./banner-github.png)
3
+ <h1 align="center">CRXJS</h1>
5
4
 
6
- [![npm (scoped)](https://img.shields.io/npm/v/@crxjs/vite-plugin.svg)](https://www.npmjs.com/package/@crxjs/vite-plugin)
7
- [![GitHub last commit](https://img.shields.io/github/last-commit/crxjs/chrome-extension-tools.svg?logo=github)](https://github.com/crxjs/rollup-plugin-chrome-extension)
8
- ![GitHub action badge](https://github.com/crxjs/chrome-extension-tools/actions/workflows/vite-plugin.yml/badge.svg)
5
+ <p align="center">
6
+ Modern Chrome extension development with built-in <code>HMR</code> and <code>zero-config</code> setup
7
+ </p>
9
8
 
10
- ## CRXJS Vite Plugin
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@crxjs/vite-plugin">
11
+ <img src="https://img.shields.io/npm/v/@crxjs/vite-plugin?color=298cd6&amp;label=CRXJS&labelColor=f2bae4" alt="NPM version">
12
+ </a>
13
+ </p>
11
14
 
12
- > Build a Chrome Extension with [Vite](https://vitejs.dev)⚡
15
+ <h2 align="center">
16
+ <a href="https://crxjs.dev/vite-plugin">📚 Documentation</a> |
17
+ <a href="https://discord.gg/5yHKEa9v">💬 Discord </a>
18
+ </h2>
13
19
 
14
- CRXJS brings the Vite developer experience to Chrome Extensions:
15
20
 
16
- - True HMR for extension pages and content scripts
17
- - Simple config - everything is in the extension manifest
18
- - Static asset imports with automatic web-accessible resources
21
+ ## 📦 Create CRXJS Project
22
+ ```shell
23
+ npm create crxjs@latest
24
+ ```
19
25
 
20
- ## Getting Started
26
+ > [!IMPORTANT]
27
+ > `@latest` MUST NOT be omitted, otherwise `npm` may resolve to a cached and outdated version of the package.
21
28
 
22
- See the CRXJS documentation to
23
- [get started in 90 seconds 🚀](https://crxjs.dev/vite-plugin)
29
+ ## ✨ Features
24
30
 
25
- ## Supporting
31
+ - 🧩 **Full Vite Plugin Ecosystem** - Leverage any Vite-compatible plugins with zero extra setup
32
+ - ⚙️ **Zero Configuration** - Start developing immediately with intelligent defaults
33
+ - 3️⃣ **Manifest V3 Support** - Built for modern Chrome extensions with enhanced security
34
+ - 🔥 **True Hot Module Replacement** - Instant UI updates while preserving extension state 🎈**works with content scripts**
35
+ - 📁 **Static Asset Import** - Directly reference images/fonts in your code
36
+ - 🤖 **Auto Web-Accessible Resources** - Automatic generation of `web_accessible_resources` manifest entries
26
37
 
27
- If these plugins have helped you ship your product faster, please consider
28
- [sponsoring me](https://github.com/sponsors/jacksteamdev) on GitHub.
38
+ > [!NOTE]
39
+ > Looking for MV2 support? See [`rollup-plugin`](packages/rollup-plugin/README.md)
40
+
41
+ ## 💝 Contributors
29
42
 
30
- ## Contributing
43
+ This project exists thanks to all the people who contribute.
31
44
 
32
- We encourage pull requests! This is a
33
- [pnpm monorepo](https://pnpm.io/workspaces), so use pnpm instead of Yarn or npm.
45
+ And thank you to all our backers! 🙏
46
+
47
+ <a href="https://github.com/crxjs/chrome-extension-tools/graphs/contributors">
48
+ <img src="https://contrib.rocks/image?repo=crxjs/chrome-extension-tools" />
49
+ </a>
50
+
51
+ ## 🤝 Supporting
52
+
53
+ If these plugins have helped you ship your product faster, please consider
54
+ [sponsoring me](https://github.com/sponsors/jacksteamdev) on GitHub.
package/dist/index.mjs CHANGED
@@ -14,9 +14,9 @@ import { createLogger, version } from 'vite';
14
14
  import { readFileSync, existsSync, promises } from 'fs';
15
15
  import { createRequire } from 'module';
16
16
  import fg from 'fast-glob';
17
+ import pc from 'picocolors';
17
18
  import { load } from 'cheerio';
18
19
  import jsesc from 'jsesc';
19
- import colors from 'picocolors';
20
20
 
21
21
  const pluginName$1 = "crx:optionsProvider";
22
22
  const pluginOptionsProvider = (options) => {
@@ -1270,6 +1270,31 @@ const pluginHMR = () => {
1270
1270
  ];
1271
1271
  };
1272
1272
 
1273
+ function printStr(dir) {
1274
+ return ` ${pc.magentaBright("B R O W S E R")}
1275
+ ${pc.greenBright("E X T E N S I O N")}
1276
+ ${pc.blueBright("T O O L S")}
1277
+
1278
+ ${pc.green("\u279C")} ${pc.bold("CRXJS")}: ${pc.green(`Load ${pc.cyan(dir)} as unpacked extension`)}`;
1279
+ }
1280
+ const pluginPrint = () => {
1281
+ let outDir = "dist";
1282
+ return [
1283
+ {
1284
+ name: "crx:print",
1285
+ enforce: "pre",
1286
+ configResolved(resolvedConfig) {
1287
+ outDir = resolvedConfig.build.outDir;
1288
+ },
1289
+ configureServer(server) {
1290
+ server.printUrls = () => {
1291
+ console.log(printStr(outDir));
1292
+ };
1293
+ }
1294
+ }
1295
+ ];
1296
+ };
1297
+
1273
1298
  var loader = "try {\n for (const p of JSON.parse(SCRIPTS)) {\n const url = new URL(p, \"https://stub\");\n url.searchParams.set(\"t\", Date.now().toString());\n const req = url.pathname + url.search;\n await import(\n /* @vite-ignore */\n req\n );\n }\n} catch (error) {\n console.error(error);\n}\n";
1274
1299
 
1275
1300
  const pluginName = "crx:html-inline-scripts";
@@ -1665,11 +1690,11 @@ const pluginManifest = () => {
1665
1690
  const name = `[${plugin.name}]`;
1666
1691
  let message = error;
1667
1692
  if (error instanceof Error) {
1668
- message = colors.red(
1693
+ message = pc.red(
1669
1694
  `${name} ${error.stack ? error.stack : error.message}`
1670
1695
  );
1671
1696
  } else if (typeof error === "string") {
1672
- message = colors.red(`${name} ${error}`);
1697
+ message = pc.red(`${name} ${error}`);
1673
1698
  }
1674
1699
  console.log(message);
1675
1700
  throw new Error(`Error in ${plugin.name}.renderCrxManifest`);
@@ -1985,7 +2010,8 @@ const crx = (options) => {
1985
2010
  pluginWebAccessibleResources(),
1986
2011
  pluginContentScriptsCss(),
1987
2012
  pluginHMR(),
1988
- pluginManifest()
2013
+ pluginManifest(),
2014
+ pluginPrint()
1989
2015
  ].flat();
1990
2016
  };
1991
2017
  const chromeExtension = crx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crxjs/vite-plugin",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Build Chrome Extensions with this Vite plugin.",
5
5
  "keywords": [
6
6
  "rollup-plugin",
@@ -92,7 +92,7 @@
92
92
  "eslint-plugin-react": "^7.29.4",
93
93
  "jest-image-snapshot": "^5.2.0",
94
94
  "npm-run-all": "^4.1.5",
95
- "playwright-chromium": "1.33.0",
95
+ "playwright-chromium": "1.52.0",
96
96
  "react": "17.0.2",
97
97
  "react-dom": "17.0.2",
98
98
  "rimraf": "3.0.2",