rsbuild-plugin-google-analytics 1.0.3 → 1.0.4
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.
- package/dist/index.cjs +57 -60
- package/dist/index.d.ts +3 -6
- package/dist/index.js +26 -38
- package/package.json +15 -12
- package/dist/index.d.cts +0 -16
package/dist/index.cjs
CHANGED
|
@@ -1,69 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
pluginGoogleAnalytics: ()=>pluginGoogleAnalytics
|
|
24
28
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
tag: "script",
|
|
46
|
-
attrs: {
|
|
47
|
-
async: true,
|
|
48
|
-
src: `https://www.googletagmanager.com/gtag/js?id=${id}`
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
tag: "script",
|
|
53
|
-
children: `
|
|
29
|
+
const pluginGoogleAnalytics = ({ id, enable = true })=>({
|
|
30
|
+
name: 'rsbuild-plugin-google-analytics',
|
|
31
|
+
setup (api) {
|
|
32
|
+
if (!enable) return;
|
|
33
|
+
if (!id) throw new Error('[rsbuild-plugin-google-analytics] Google tag ID is required!');
|
|
34
|
+
api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig })=>{
|
|
35
|
+
const extraConfig = {
|
|
36
|
+
html: {
|
|
37
|
+
tags: [
|
|
38
|
+
{
|
|
39
|
+
tag: "script",
|
|
40
|
+
attrs: {
|
|
41
|
+
async: true,
|
|
42
|
+
src: `https://www.googletagmanager.com/gtag/js?id=${id}`
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
tag: "script",
|
|
47
|
+
children: `
|
|
54
48
|
window.dataLayer = window.dataLayer || [];
|
|
55
49
|
function gtag(){dataLayer.push(arguments);}
|
|
56
50
|
gtag('js', new Date());
|
|
57
51
|
gtag('config', '${id}');`
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
57
|
+
});
|
|
60
58
|
}
|
|
61
|
-
};
|
|
62
|
-
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
63
59
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
exports.pluginGoogleAnalytics = __webpack_exports__.pluginGoogleAnalytics;
|
|
61
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
62
|
+
"pluginGoogleAnalytics"
|
|
63
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
64
|
+
Object.defineProperty(exports, '__esModule', {
|
|
65
|
+
value: true
|
|
69
66
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
|
|
3
|
-
type PluginGoogleAnalyticsOptions = {
|
|
1
|
+
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
+
export type PluginGoogleAnalyticsOptions = {
|
|
4
3
|
/**
|
|
5
4
|
* Google tag ID.
|
|
6
5
|
*/
|
|
@@ -11,6 +10,4 @@ type PluginGoogleAnalyticsOptions = {
|
|
|
11
10
|
*/
|
|
12
11
|
enable?: boolean;
|
|
13
12
|
};
|
|
14
|
-
declare const pluginGoogleAnalytics: ({ id, enable, }: PluginGoogleAnalyticsOptions) => RsbuildPlugin;
|
|
15
|
-
|
|
16
|
-
export { type PluginGoogleAnalyticsOptions, pluginGoogleAnalytics };
|
|
13
|
+
export declare const pluginGoogleAnalytics: ({ id, enable, }: PluginGoogleAnalyticsOptions) => RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,44 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
tag: "script",
|
|
22
|
-
attrs: {
|
|
23
|
-
async: true,
|
|
24
|
-
src: `https://www.googletagmanager.com/gtag/js?id=${id}`
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
tag: "script",
|
|
29
|
-
children: `
|
|
1
|
+
const pluginGoogleAnalytics = ({ id, enable = true })=>({
|
|
2
|
+
name: 'rsbuild-plugin-google-analytics',
|
|
3
|
+
setup (api) {
|
|
4
|
+
if (!enable) return;
|
|
5
|
+
if (!id) throw new Error('[rsbuild-plugin-google-analytics] Google tag ID is required!');
|
|
6
|
+
api.modifyRsbuildConfig((userConfig, { mergeRsbuildConfig })=>{
|
|
7
|
+
const extraConfig = {
|
|
8
|
+
html: {
|
|
9
|
+
tags: [
|
|
10
|
+
{
|
|
11
|
+
tag: "script",
|
|
12
|
+
attrs: {
|
|
13
|
+
async: true,
|
|
14
|
+
src: `https://www.googletagmanager.com/gtag/js?id=${id}`
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
tag: "script",
|
|
19
|
+
children: `
|
|
30
20
|
window.dataLayer = window.dataLayer || [];
|
|
31
21
|
function gtag(){dataLayer.push(arguments);}
|
|
32
22
|
gtag('js', new Date());
|
|
33
23
|
gtag('config', '${id}');`
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
29
|
+
});
|
|
36
30
|
}
|
|
37
|
-
};
|
|
38
|
-
return mergeRsbuildConfig(extraConfig, userConfig);
|
|
39
31
|
});
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
export {
|
|
43
|
-
pluginGoogleAnalytics
|
|
44
|
-
};
|
|
32
|
+
export { pluginGoogleAnalytics };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-google-analytics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-google-analytics",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,27 +17,30 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rslib build",
|
|
22
|
+
"dev": "rslib build --watch",
|
|
23
|
+
"prepare": "npm run build",
|
|
24
|
+
"bump": "npx bumpp"
|
|
25
|
+
},
|
|
20
26
|
"devDependencies": {
|
|
21
|
-
"@rsbuild/core": "^1.
|
|
22
|
-
"@
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"typescript": "^5.
|
|
27
|
+
"@rsbuild/core": "^1.4.12",
|
|
28
|
+
"@rslib/core": "^0.11.0",
|
|
29
|
+
"@types/node": "^22.17.0",
|
|
30
|
+
"prettier": "^3.6.2",
|
|
31
|
+
"typescript": "^5.9.2"
|
|
26
32
|
},
|
|
27
33
|
"peerDependencies": {
|
|
28
|
-
"@rsbuild/core": "
|
|
34
|
+
"@rsbuild/core": "1.x"
|
|
29
35
|
},
|
|
30
36
|
"peerDependenciesMeta": {
|
|
31
37
|
"@rsbuild/core": {
|
|
32
38
|
"optional": true
|
|
33
39
|
}
|
|
34
40
|
},
|
|
41
|
+
"packageManager": "pnpm@10.14.0",
|
|
35
42
|
"publishConfig": {
|
|
36
43
|
"access": "public",
|
|
37
44
|
"registry": "https://registry.npmjs.org/"
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsup",
|
|
41
|
-
"dev": "tsup --watch"
|
|
42
45
|
}
|
|
43
|
-
}
|
|
46
|
+
}
|
package/dist/index.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
|
|
3
|
-
type PluginGoogleAnalyticsOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* Google tag ID.
|
|
6
|
-
*/
|
|
7
|
-
id: string;
|
|
8
|
-
/**
|
|
9
|
-
* Whether to enable Google Analytics.
|
|
10
|
-
* @default true
|
|
11
|
-
*/
|
|
12
|
-
enable?: boolean;
|
|
13
|
-
};
|
|
14
|
-
declare const pluginGoogleAnalytics: ({ id, enable, }: PluginGoogleAnalyticsOptions) => RsbuildPlugin;
|
|
15
|
-
|
|
16
|
-
export { type PluginGoogleAnalyticsOptions, pluginGoogleAnalytics };
|