2025-08-09 14:56:10 +08:00
2024-03-04 22:43:53 +08:00
2024-03-04 22:43:53 +08:00
2025-08-09 14:56:10 +08:00
2024-03-04 22:43:53 +08:00
2024-03-04 22:43:53 +08:00
2024-03-04 22:59:38 +08:00
2024-03-04 22:30:27 +08:00
2024-03-06 11:11:59 +08:00
2024-03-04 22:49:00 +08:00
2024-03-04 22:43:53 +08:00

vite-plugin-adsense

Insert Google AdSense script to index.html and create ads.txt file.

Why or who need it?

If your code powers many different websites, and each site use a different AdSense account, this plugin is made for you. You can configure different AdSense account in .env file for each site.

Install

npm i vite-plugin-adsense

Usage

It is recommended to save your client id into .env file.

# .env
VITE_ADSENSE_CLIENT=ca-pub-1234567890123456
// vite.config.ts
import { defineConfig } from 'vite';
import adsense from 'vite-plugin-adsense';

export default defineConfig({
  plugins: [adsense()],
});

If you have more advanced usage, you can also pass client to plugin options.

// vite.config.ts
import { defineConfig } from 'vite';
import adsense from 'vite-plugin-adsense';

export default defineConfig({
  plugins: [
    adsense({
      client: 'ca-pub-1234567890123456',
    }),
  ],
});
S
Description
Insert Google AdSense script to index.html and create ads.txt file
Readme MPL-2.0 388 KiB
Languages
TypeScript 100%