Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hairyf/unplugin-scripts
continuously executing scripts
https://github.com/hairyf/unplugin-scripts
Last synced: about 1 month ago
JSON representation
continuously executing scripts
- Host: GitHub
- URL: https://github.com/hairyf/unplugin-scripts
- Owner: hairyf
- License: mit
- Created: 2023-04-28T04:47:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-15T05:20:08.000Z (about 1 year ago)
- Last Synced: 2024-10-03T08:21:01.110Z (3 months ago)
- Language: TypeScript
- Size: 75.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unplugin-scripts
Better use of scripts for Vite, Webpack, Rollup and esbuild. With TypeScript support. Powered by [unplugin](https://github.com/unjs/unplugin).
## Install
```bash
npm i unplugin-scripts
```Vite
```ts
// vite.config.ts
import Scripts from 'unplugin-scripts/vite'export default defineConfig({
plugins: [
Scripts([/* options */]),
],
})
```Example: [`playground/`](./playground/)
Rollup
```ts
// rollup.config.js
import Scripts from 'unplugin-scripts/rollup'export default {
plugins: [
Scripts([/* options */]),
],
}
```
Webpack
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-scripts/webpack')([/* options */])
]
}
```
Nuxt
```ts
// nuxt.config.js
export default {
buildModules: [
['unplugin-scripts/nuxt', [/* options */]],
],
}
```> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
Vue CLI
```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-scripts/webpack')([/* options */]),
],
},
}
```
esbuild
```ts
// esbuild.config.js
import { build } from 'esbuild'
import Scripts from 'unplugin-scripts/esbuild'build({
plugins: [Scripts()],
})
```
## Basic for Vite
```ts
// vite.config.ts
import Scripts from 'unplugin-scripts/vite'function clear() {
// ...
}export default defineConfig(({ command }) => {
return {
plugins: [
Scripts([
// only execute once
{ script: 'node scripts/update.js' },
// continuously executing scripts
{ script: 'api-generate', interval: 100000 },
// only build execute
{
script: 'vue-tsc',
invoke: () => command === 'prod'
},
// execute function
{ script: clear },
]),
],
}
})
```## License
[MIT](./LICENSE) License © 2023 [Hairyf](https://github.com/hairyf)