vite-plugin-adsense
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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',
    }),
  ],
});

Package Sidebar

Install

npm i vite-plugin-adsense

Weekly Downloads

4

Version

1.1.1

License

MIT

Unpacked Size

5.94 kB

Total Files

6

Last publish

Collaborators

  • guoyunhe