File tree Expand file tree Collapse file tree 13 files changed +870
-132
lines changed Expand file tree Collapse file tree 13 files changed +870
-132
lines changed Original file line number Diff line number Diff line change 1212- 🔧 Configure Tampermonkey's Userscript header.
1313- 💨 Import all ` grant ` by default in development mode.
1414- 📝 Automatically add used ` grant ` when building for production.
15+ - 📦 Built-in Tampermonkey's TypeScript type difinition.
1516
1617## Install
1718
@@ -36,21 +37,23 @@ import { defineConfig } from 'vite'
3637import Userscript from ' vite-userscript-plugin'
3738import { name , version } from ' ./package.json'
3839
39- export default defineConfig ({
40- plugins: [
41- Userscript ({
42- entry: ' src/index.ts' ,
43- header: {
44- name,
45- version,
46- match: [
47- ' https://example.com' ,
48- ' https://example.org' ,
49- ' https://example.edu'
50- ]
51- }
52- })
53- ]
40+ export default defineConfig ((config ) => {
41+ return {
42+ plugins: [
43+ Userscript ({
44+ entry: ' src/index.ts' ,
45+ header: {
46+ name,
47+ version,
48+ match: [
49+ ' *://example.com' ,
50+ ' *://example.org' ,
51+ ' *://example.edu'
52+ ]
53+ }
54+ })
55+ ]
56+ }
5457})
5558```
5659
@@ -65,6 +68,18 @@ export default defineConfig({
6568}
6669```
6770
71+ ### ` tsconfig.json `
72+
73+ ``` json
74+ {
75+ "compilerOptions" : {
76+ "types" : [
77+ " vite-userscript-plugin/tampermonkey"
78+ ]
79+ }
80+ }
81+ ```
82+
6883## Plugin Configuration
6984
7085``` ts
Original file line number Diff line number Diff line change 44 "version" : " 0.0.0" ,
55 "type" : " module" ,
66 "scripts" : {
7- "dev" : " vite build --watch" ,
7+ "dev" : " vite build --watch --mode development " ,
88 "build" : " vite build"
99 },
1010 "devDependencies" : {
Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ import './styles/style.sass'
44
55const div = document . querySelector ( 'div' ) !
66div . appendChild ( createButton ( ) )
7+
8+ GM_addStyle ( '' )
Original file line number Diff line number Diff line change 11/// <reference types="vite/client" />
2+ /// <reference types="vite-userscript-plugin/tampermonkey" />
Original file line number Diff line number Diff line change 11{
22 "extends" : " @crashmax/tsconfig" ,
33 "compilerOptions" : {
4- "outDir" : " dist" ,
5- "resolveJsonModule" : true
6- }
4+ "outDir" : " dist"
5+ },
6+ "include" : [
7+ " src/**/*"
8+ ]
79}
Original file line number Diff line number Diff line change @@ -2,19 +2,24 @@ import { defineConfig } from 'vite'
22import Userscript from 'vite-userscript-plugin'
33import { name , version } from './package.json'
44
5- export default defineConfig ( {
6- plugins : [
7- Userscript ( {
8- entry : 'src/index.ts' ,
9- header : {
10- name,
11- version,
12- match : [
13- '*://example.com' ,
14- '*://example.org' ,
15- '*://example.edu'
16- ]
17- }
18- } )
19- ]
5+ export default defineConfig ( ( config ) => {
6+ return {
7+ plugins : [
8+ Userscript ( {
9+ entry : 'src/index.ts' ,
10+ header : {
11+ name,
12+ version,
13+ match : [
14+ '*://example.com' ,
15+ '*://example.org' ,
16+ '*://example.edu'
17+ ]
18+ } ,
19+ server : {
20+ port : 3000
21+ }
22+ } )
23+ ]
24+ }
2025} )
Original file line number Diff line number Diff line change 44 "version" : " 0.0.0" ,
55 "type" : " module" ,
66 "scripts" : {
7- "dev" : " vite build --watch" ,
7+ "dev" : " vite build --watch --mode development " ,
88 "build" : " vite build"
99 },
1010 "devDependencies" : {
1313 "vite-userscript-plugin" : " workspace:*"
1414 },
1515 "dependencies" : {
16- "redom-jsx" : " ^3.29.3 "
16+ "redom-jsx" : " ^3.29.4 "
1717 }
1818}
Original file line number Diff line number Diff line change 22 "extends" : " @crashmax/tsconfig" ,
33 "compilerOptions" : {
44 "outDir" : " dist" ,
5- "resolveJsonModule" : true ,
6- "jsx" : " preserve"
5+ "jsx" : " preserve" ,
6+ "types" : [
7+ " vite-userscript-plugin/tampermonkey"
8+ ]
79 },
810 "include" : [
9- " src"
11+ " src/**/* "
1012 ]
1113}
Original file line number Diff line number Diff line change @@ -3,16 +3,21 @@ import Redom from 'vite-redom-jsx'
33import Userscript from 'vite-userscript-plugin'
44import { name , version } from './package.json'
55
6- export default defineConfig ( {
7- plugins : [
8- Redom ( ) ,
9- Userscript ( {
10- entry : 'src/index.tsx' ,
11- header : {
12- name,
13- version,
14- match : '*://example.com'
15- }
16- } )
17- ]
6+ export default defineConfig ( ( config ) => {
7+ return {
8+ plugins : [
9+ Redom ( ) ,
10+ Userscript ( {
11+ entry : 'src/index.tsx' ,
12+ header : {
13+ name,
14+ version,
15+ match : '*://example.com'
16+ } ,
17+ server : {
18+ port : 4000
19+ }
20+ } )
21+ ]
22+ }
1823} )
Original file line number Diff line number Diff line change 1010 "import" : " ./dist/index.js"
1111 },
1212 "files" : [
13- " dist"
13+ " dist" ,
14+ " tampermonkey.d.ts"
1415 ],
1516 "scripts" : {
1617 "dev" : " tsup --watch" ,
4445 "url" : " https://github.com/crashmax-dev/vite-userscript-plugin/issues"
4546 },
4647 "dependencies" : {
47- "@types/tampermonkey" : " ^4.0.5" ,
4848 "get-port" : " ^6.1.2" ,
4949 "open" : " ^8.4.0" ,
5050 "picocolors" : " ^1.0.0" ,
6060 "@types/websocket" : " ^1.0.5" ,
6161 "@vitest/ui" : " ^0.23.2" ,
6262 "tsup" : " ^6.2.3" ,
63- "turbo" : " ^1.4.6 " ,
63+ "turbo" : " ^1.4.7 " ,
6464 "typescript" : " ^4.8.3" ,
65- "vite" : " ^3.1.1 " ,
65+ "vite" : " ^3.1.2 " ,
6666 "vite-plugin-dts" : " ^1.5.0" ,
6767 "vitest" : " ^0.23.2"
6868 },
6969 "peerDependencies" : {
70- "@types/tampermonkey" : " >=4.0.0" ,
7170 "vite" : " >=2.9.0"
7271 }
7372}
You can’t perform that action at this time.
0 commit comments