Remote Code
In Manifest V3, the remote code is not allowed according to the Chrome Web Store policy. Never mind, you can use Rspack's buildHttp
feature to support building remote code. The configuration is as follows:
ts
import { defineConfig } from '@rsbuild/core';
export default defineConfig({
tools: {
rspack: {
experiments: {
buildHttp: {
allowedUris: [/https?:\/\//],
},
},
},
},
});
Google Analytics
You can refer to the following code for importing Google Analytics.
ts
import 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXX';
window.dataLayer = window.dataLayer || [];
export function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-XXXXXX');