replace magic string in gtag

This commit is contained in:
geekgeekrun
2024-10-24 02:01:25 +08:00
parent 48c65cb50a
commit 7a3bddbd0c
4 changed files with 69 additions and 1 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
node_modules
database.sqlite
.env.local

View File

@@ -1,10 +1,12 @@
import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import { defineConfig, externalizeDepsPlugin, loadEnv } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import { presetUno, presetAttributify, presetIcons } from 'unocss'
import transformerDirective from "@unocss/transformer-directives";
import Replace from 'unplugin-replace/vite'
process.env = { ...process.env, ...loadEnv(process.env.NODE_ENV!, process.cwd()) }
export default defineConfig({
main: {
build: {
@@ -15,6 +17,21 @@ export default defineConfig({
plugins: [
externalizeDepsPlugin({
exclude: ['@geekgeekrun/geek-auto-start-chat-with-boss', '@geekgeekrun/dingtalk-plugin', '@geekgeekrun/utils', 'find-chrome-bin', '@geekgeekrun/launch-bosszhipin-login-page-with-preload-extension']
}),
Replace({
delimiters: ['', ''],
sourcemap: true,
include: ['**/src/main/utils/gtag/Analytics.ts'],
values: [
{
find: /<measurement_id>/g,
replacement: process.env.VITE_APP_GTAG_MEASUREMENT_ID as string,
},
{
find: /<api_secret>/g,
replacement: process.env.VITE_APP_GTAG_API_SECRET as string,
}
]
})
]
},

View File

@@ -71,6 +71,7 @@
"typescript": "^5.3.3",
"unocss": "^0.58.5",
"unplugin-auto-import": "^0.17.5",
"unplugin-replace": "^0.3.3",
"unplugin-vue-components": "^0.26.0",
"vite": "^5.0.12",
"vue": "^3.4.15",

48
pnpm-lock.yaml generated
View File

@@ -217,6 +217,9 @@ importers:
unplugin-auto-import:
specifier: ^0.17.5
version: 0.17.5
unplugin-replace:
specifier: ^0.3.3
version: 0.3.3
unplugin-vue-components:
specifier: ^0.26.0
version: 0.26.0(vue@3.4.15)
@@ -1073,6 +1076,10 @@ packages:
/@jridgewell/sourcemap-codec@1.4.15:
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
/@jridgewell/sourcemap-codec@1.5.0:
resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==}
dev: true
/@jridgewell/trace-mapping@0.3.22:
resolution: {integrity: sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==}
dependencies:
@@ -2094,6 +2101,12 @@ packages:
engines: {node: '>=0.4.0'}
hasBin: true
/acorn@8.13.0:
resolution: {integrity: sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: true
/agent-base@6.0.2:
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
engines: {node: '>= 6.0.0'}
@@ -4280,6 +4293,12 @@ packages:
engines: {node: '>=12'}
dev: true
/magic-string@0.30.12:
resolution: {integrity: sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==}
dependencies:
'@jridgewell/sourcemap-codec': 1.5.0
dev: true
/magic-string@0.30.7:
resolution: {integrity: sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA==}
engines: {node: '>=12'}
@@ -5964,6 +5983,18 @@ packages:
- rollup
dev: true
/unplugin-replace@0.3.3:
resolution: {integrity: sha512-EHv9QpShJSez8jinjXAlpBeQwj5gQt4ZLkEjqOlYfMladTTDAlrIgGmcOYzXMK7SGjQCaXD2srsWVkHV3DDSjw==}
engines: {node: '>=18.0.0'}
dependencies:
'@rollup/pluginutils': 5.1.0
magic-string: 0.30.12
unplugin: 1.14.1
transitivePeerDependencies:
- rollup
- webpack-sources
dev: true
/unplugin-vue-components@0.26.0(vue@3.4.15):
resolution: {integrity: sha512-s7IdPDlnOvPamjunVxw8kNgKNK8A5KM1YpK5j/p97jEKTjlPNrA0nZBiSfAKKlK1gWZuyWXlKL5dk3EDw874LQ==}
engines: {node: '>=14'}
@@ -5993,6 +6024,19 @@ packages:
- supports-color
dev: true
/unplugin@1.14.1:
resolution: {integrity: sha512-lBlHbfSFPToDYp9pjXlUEFVxYLaue9f9T1HC+4OHlmj+HnMDdz9oZY+erXfoCe/5V/7gKUSY2jpXPb9S7f0f/w==}
engines: {node: '>=14.0.0'}
peerDependencies:
webpack-sources: ^3
peerDependenciesMeta:
webpack-sources:
optional: true
dependencies:
acorn: 8.13.0
webpack-virtual-modules: 0.6.2
dev: true
/unplugin@1.7.1:
resolution: {integrity: sha512-JqzORDAPxxs8ErLV4x+LL7bk5pk3YlcWqpSNsIkAZj972KzFZLClc/ekppahKkOczGkwIG6ElFgdOgOlK4tXZw==}
dependencies:
@@ -6177,6 +6221,10 @@ packages:
resolution: {integrity: sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==}
dev: true
/webpack-virtual-modules@0.6.2:
resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==}
dev: true
/whatwg-url@5.0.0:
resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==}
dependencies: