migrate
This commit is contained in:
+2
-1
@@ -6,5 +6,6 @@ end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 100
|
||||
quote_type = single
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: latest
|
||||
- run: pnpm install
|
||||
- run: pnpm run lint
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: latest
|
||||
- run: pnpm install
|
||||
- run: pnpm run test
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: latest
|
||||
- run: pnpm install
|
||||
- run: pnpm run build
|
||||
@@ -0,0 +1,29 @@
|
||||
name: GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: latest
|
||||
- run: pnpm install
|
||||
- run: pnpm run build
|
||||
- uses: peaceiris/actions-gh-pages@v3
|
||||
if: github.ref == 'refs/heads/main'
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./build
|
||||
+4
-12
@@ -1,16 +1,8 @@
|
||||
# Build output
|
||||
dist
|
||||
|
||||
# Coverage directory
|
||||
.rive
|
||||
build
|
||||
coverage
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
|
||||
# Lock files
|
||||
dist
|
||||
node_modules
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
Vendored
+4
-2
@@ -2,6 +2,8 @@
|
||||
"recommendations": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"editorconfig.editorconfig",
|
||||
"esbenp.prettier-vscode"
|
||||
"esbenp.prettier-vscode",
|
||||
"stylelint.vscode-stylelint",
|
||||
"unifiedjs.vscode-mdx"
|
||||
]
|
||||
}
|
||||
}
|
||||
Vendored
+33
-4
@@ -1,11 +1,14 @@
|
||||
{
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"typescript"
|
||||
"typescript",
|
||||
"javascriptreact",
|
||||
"typescriptreact"
|
||||
],
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll.eslint": true,
|
||||
"source.organizeImports": true
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.organizeImports": "explicit",
|
||||
"source.fixAll.stylelint": "explicit"
|
||||
},
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
@@ -23,5 +26,31 @@
|
||||
},
|
||||
"[jsonc]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"stylelint.validate": [
|
||||
"css",
|
||||
"less",
|
||||
"scss"
|
||||
],
|
||||
"[javascriptreact]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[css]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[less]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[scss]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[html]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## 1.0.0 - 2023-03-30
|
||||
## 2024-03-04
|
||||
|
||||
- First version, support `client` option and `VITE_ADSENSE_CLIENT` env
|
||||
- Changed license to MIT
|
||||
|
||||
@@ -15,6 +15,8 @@ npm i vite-plugin-adsense
|
||||
|
||||
## Usage
|
||||
|
||||
It is recommended to save your client id into `.env` file.
|
||||
|
||||
```ini
|
||||
# .env
|
||||
VITE_ADSENSE_CLIENT=ca-pub-1234567890123456
|
||||
@@ -29,3 +31,17 @@ export default defineConfig({
|
||||
plugins: [adsense()],
|
||||
});
|
||||
```
|
||||
|
||||
If you have more advanced usage, you can also pass `client` to plugin options.
|
||||
|
||||
```ts
|
||||
// vite.config.ts
|
||||
import { defineConfig } from 'vite';
|
||||
import adsense from 'vite-plugin-adsense';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [adsense({
|
||||
client: 'ca-pub-1234567890123456',
|
||||
})],
|
||||
});
|
||||
```
|
||||
|
||||
+30
-22
@@ -19,14 +19,15 @@
|
||||
"url": "git+https://github.com/guoyunhe/vite-plugin-adsense.git"
|
||||
},
|
||||
"funding": "https://github.com/sponsors/guoyunhe",
|
||||
"license": "GPL-3.0",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Guo Yunhe",
|
||||
"email": "i@guoyunhe.me"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.mjs",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"CHANGELOG.md",
|
||||
@@ -34,28 +35,35 @@
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "node-scripts build",
|
||||
"format": "node-scripts format",
|
||||
"lint": "node-scripts lint",
|
||||
"test": "node-scripts test",
|
||||
"watch": "node-scripts watch"
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 100,
|
||||
"singleQuote": true
|
||||
"build": "rive build",
|
||||
"build:watch": "rive build --watch",
|
||||
"lint": "rive lint",
|
||||
"lint:fix": "rive lint --fix",
|
||||
"start": "rive start",
|
||||
"test": "rive test",
|
||||
"test:ui": "rive test --ui",
|
||||
"test:watch": "rive test --watch"
|
||||
},
|
||||
"prettier": "prettier-config-rive",
|
||||
"eslintConfig": {
|
||||
"extends": "@guoyunhe/node-scripts"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "@guoyunhe/node-scripts"
|
||||
"extends": "eslint-config-rive"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@guoyunhe/node-scripts": "^2.0.0",
|
||||
"@tsconfig/node16": "^1.0.0",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/node": "^16.0.0",
|
||||
"typescript": "^4.0.0",
|
||||
"vite": "^4.2.1"
|
||||
"@mdx-js/react": "^3.0.1",
|
||||
"@types/node": "^16.18.86",
|
||||
"@types/react": "^18.2.61",
|
||||
"@types/react-dom": "^18.2.19",
|
||||
"react": "^18.2.0",
|
||||
"react-doc-ui": "^2.2.6",
|
||||
"react-dom": "^18.2.0",
|
||||
"rive": "^2.0.33",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"rive": {
|
||||
"template": "node",
|
||||
"doc": {
|
||||
"basename": "/vite-plugin-adsense/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ export default function adsense({ client }: AdSenseOptions = {}): Plugin {
|
||||
// insert adsense script to the end of index.html
|
||||
return html.replace(
|
||||
/<\/body>/,
|
||||
` <script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${actualClient}" crossorigin="anonymous" defer></script>\n</body>`
|
||||
` <script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${actualClient}" crossorigin="anonymous" defer></script>\n</body>`,
|
||||
);
|
||||
},
|
||||
closeBundle: async () => {
|
||||
@@ -34,7 +34,7 @@ export default function adsense({ client }: AdSenseOptions = {}): Plugin {
|
||||
// create ads.txt file
|
||||
await writeFile(
|
||||
join(outDir, 'ads.txt'),
|
||||
`google.com, ${actualClient.substring(3)}, DIRECT, f08c47fec0942fa0\n`
|
||||
`google.com, ${actualClient.substring(3)}, DIRECT, f08c47fec0942fa0\n`,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
+25
-3
@@ -1,8 +1,30 @@
|
||||
{
|
||||
"extends": "@tsconfig/node16/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"types": ["node", "jest", "@guoyunhe/node-scripts/global"]
|
||||
"types": [
|
||||
"node",
|
||||
"rive/globals"
|
||||
],
|
||||
"target": "es2015",
|
||||
"lib": [
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"isolatedModules": true
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": [
|
||||
"src"
|
||||
],
|
||||
"exclude": [
|
||||
".rive",
|
||||
"build",
|
||||
"coverage",
|
||||
"dist",
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user