Closed snordquist closed 1 year ago
vite has vite build
and vite serve
two mode, if you use vite serve
, the number of entry must be one
if you just build
multiple entry, you can use vite build api
// custom_build.ts
import { build } from 'vite';
import monkey from 'vite-plugin-monkey';
await build({
configFile: false,
plugins: [
monkey({
entry: 'src/entry1.ts',
userscript: {
namespace: 'namespace',
},
build: {
fileName: 'out1.user.js',
},
}),
],
});
await build({
configFile: false,
plugins: [
monkey({
entry: 'src/entry2.ts',
userscript: {
namespace: 'namespace',
},
build: {
fileName: 'out2.user.js',
},
}),
],
});
you can use tsx run it
pnpm exec tsx ./custom_build.ts
if you want to manage multiple userscript/package in single git repository
you can use monorepo, pnpm monorepo is a widely used one in its implementation
the following repository all are based pnpm monorepo
such as userscripts
pnpm -F package_name serve
// startup one project serve script
pnpm -r --filter=./packages/* serve
// startup all serve script
pnpm -F package_name build
// startup one project build
pnpm -r --filter=./packages/* build
// startup all build
Currently only
out2.user.js
is written, containing both userscript headers, which does not work with tampermonkey.