YuCheng Hu 44cfcac889
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
GitHub Pages / Deploy (push) Has been cancelled
Update Package
2026-02-20 07:58:55 -05:00
2024-03-04 22:43:53 +08:00
2026-02-20 07:58:55 -05: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
2026-02-20 07:58:55 -05:00
2025-08-09 14:57:58 +08:00
2025-08-09 15:00:17 +08:00
2026-02-20 07:58:55 -05: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',
    }),
  ],
});
Description
Insert Google AdSense script to index.html and create ads.txt file
Readme MPL-2.0 388 KiB
Languages
TypeScript 100%