Skip to content
Merged

Dev #83

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
with:
version: 10
- run: npm run deps
- run: npm run build:vite-plugin-deps
- run: npm run release:all
- run: npm run build:vite-plugin-deps # 构建 vite-plugin 依赖
- run: npm run build:starters # 构建 starter 依赖
- run: npm run release:all # 发布所有包
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vite-plugins

> `vite-plugins` is a collection of custom plugins designed to enhance the functionality of the Vite build tool.
> A collection of custom plugins designed to enhance the functionality of the Vite build tool.

## Plugin List

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"release:all": "node ./release.mjs",
"build:vite-plugin-deps": "pnpm run --parallel --filter=vite-plugin-external... build:lib",
"build:all": "npm run build:vite-plugin-deps && pnpm run --parallel --filter=vite-plugin-* --filter=!vite-plugin-external build:lib",
"build:vite-plugin-deps": "pnpm run --parallel --filter=vite-plugin-external... build",
"build:starters": "pnpm run --parallel --filter=*-starter^... build",
"build:all": "npm run build:vite-plugin-deps && pnpm run --parallel --filter=vite-plugin-* --filter=!vite-plugin-external build",
"test:all": "npm run build:all && pnpm run --filter=*-demo -r --parallel /^build:*/"
},
"repository": {
Expand All @@ -29,6 +30,7 @@
"dependencies": {
"cross-spawn": "^7.0.6",
"markdown-it-mathjax3": "^4.3.2",
"picocolors": "^1.0.0",
"undici": "^7.8.0",
"vitepress": "^1.6.3",
"vitepress-plugin-group-icons": "^1.3.8"
Expand Down
2 changes: 2 additions & 0 deletions packages/create-vite-lib-starter/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
8 changes: 7 additions & 1 deletion packages/create-vite-lib-starter/bin/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { basename, dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

import { generateStarter } from 'cs-runtime-helper';
import { ensureDir } from 'fs-extra';
import { generateStarter } from 'vp-runtime-helper';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand All @@ -20,10 +20,16 @@ async function run() {
const templateDir = resolve(__dirname, '..');
const packageName = basename(targetDir);

const startTime = Date.now();
await generateStarter(templateDir, targetDir, {
name: packageName,
version: '1.0.0',
files: [
'dist'
],
dependencies: {}
});
console.info(`Generated '${packageName}' in ${(Date.now() - startTime)} ms.`);
}

run();
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from 'vitepress'
import { generateAPISidebar } from './shared.mts'
import { generateAPISidebar } from './shared.mjs'

// https://vitepress.dev/reference/site-config
export const en = defineConfig({
description: "A collection of custom plugins designed to enhance the functionality of the Vite build tool.",
description: "Here is description.",
lang: 'en-US',
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
Expand Down Expand Up @@ -34,7 +34,7 @@ export const en = defineConfig({
},

socialLinks: [
{ icon: 'github', link: 'https://github.com/fengxinming/create-vite-lib-starter.git' }
{ icon: 'github', link: 'https://github.com/fengxinming/vite-plugins' }
]
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const shared = defineConfig({
// We use `[!!code` in demo to prevent transformation, here we revert it back.
{
postprocess(code) {
return code.replace(/\[\!\!code/g, '[!code')
return code.replace(/\[!!code/g, '[!code');
}
}
],
Expand Down Expand Up @@ -49,7 +49,7 @@ export const shared = defineConfig({

themeConfig: {
socialLinks: [
{ icon: 'github', link: 'https://github.com/fengxinming/create-vite-lib-starter' }
{ icon: 'github', link: 'https://github.com/fengxinming/vite-plugins' }
]
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from 'vitepress'
import { generateAPISidebar } from './shared.mts'
import { generateAPISidebar } from './shared.mjs'

// https://vitepress.dev/reference/site-config
export const zh = defineConfig({
description: "一个包含多个自定义插件的集合,用于增强 Vite 构建工具的功能。",
description: "这里是描述。",
lang: 'zh-CN',
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
Expand Down Expand Up @@ -34,7 +34,7 @@ export const zh = defineConfig({
},

socialLinks: [
{ icon: 'github', link: 'https://github.com/fengxinming/create-vite-lib-starter.git' }
{ icon: 'github', link: 'https://github.com/fengxinming/vite-plugins' }
]
}
})
8 changes: 3 additions & 5 deletions packages/create-vite-lib-starter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-vite-lib-starter",
"version": "1.0.0",
"version": "1.0.5",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"main": "dist/index.js",
Expand Down Expand Up @@ -45,9 +45,7 @@
},
"dependencies": {
"@types/fs-extra": "^11.0.4",
"cs-runtime-helper": "workspace:^",
"fs-extra": "^11.3.0"
},
"files": [
"dist/"
]
}
}
2 changes: 2 additions & 0 deletions packages/create-vite-lib-starter/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"include": [
"./src/**/*.ts",
"./test/*.ts",
"./docs/.vitepress/**/*.ts",
"./docs/.vitepress/**/*.mts",
"./node_modules/vite/client.d.ts",
"./vite.config.mts"
]
Expand Down
21 changes: 21 additions & 0 deletions packages/cs-runtime-helper/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Jesse Feng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions packages/cs-runtime-helper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# cs-runtime-helper

[![npm package](https://nodei.co/npm/cs-runtime-helper.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/cs-runtime-helper)

> Helper functions used when developing create starter

[![NPM version](https://img.shields.io/npm/v/cs-runtime-helper.svg?style=flat)](https://npmjs.org/package/cs-runtime-helper)
[![NPM Downloads](https://img.shields.io/npm/dm/cs-runtime-helper.svg?style=flat)](https://npmjs.org/package/cs-runtime-helper)

## Installation

```bash
npm install cs-runtime-helper --save
```
43 changes: 43 additions & 0 deletions packages/cs-runtime-helper/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "cs-runtime-helper",
"version": "1.0.0",
"description": "Create starter runtime helper.",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"main": "dist/index.js",
"engines": {
"node": ">=14.18.0",
"vite": ">=3.1.0"
},
"scripts": {
"build": "vite build",
"watch": "vite build --watch",
"prepublishOnly": "npm run build",
"release": "npm publish"
},
"repository": {
"type": "git",
"url": "git+https://github.com/fengxinming/vite-plugins.git",
"directory": "packages/cs-runtime-helper"
},
"keywords": [
"vite",
"cs-runtime-helper"
],
"author": "Jesse Feng <fxm0016@126.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/fengxinming/vite-plugins/issues"
},
"homepage": "https://fengxinming.github.io/vite-plugins/",
"devDependencies": {
"@rollup/plugin-typescript": "^12.1.2",
"vite": "^6.1.0"
},
"dependencies": {
"fs-extra": "^11.3.0"
},
"files": [
"dist"
]
}
1 change: 1 addition & 0 deletions packages/cs-runtime-helper/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './generateStarter';
15 changes: 15 additions & 0 deletions packages/cs-runtime-helper/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"declarationDir": "dist"
},
"include": [
"src",
"./node_modules/vite/client.d.ts"
],
"exclude": [
"dist"
]
}
31 changes: 31 additions & 0 deletions packages/cs-runtime-helper/vite.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { builtinModules } from 'node:module';

import ts from '@rollup/plugin-typescript';
import { defineConfig } from 'vite';

import { dependencies } from './package.json';

const externals = Object.keys(dependencies)
.concat(builtinModules, 'vite')
.map((n) => new RegExp(`^${n}/?`))
.concat(/^node:/);

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
ts({
tsconfig: './tsconfig.build.json'
})
],
build: {
lib: {
entry: 'src/index.ts',
formats: ['es', 'cjs'],
fileName: '[name]'
},
minify: false,
rollupOptions: {
external: externals
}
}
});
4 changes: 2 additions & 2 deletions packages/vite-plugin-build-chunk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"vite": ">=3.1.0"
},
"scripts": {
"build:lib": "vite build",
"build": "vite build",
"watch": "vite build --watch",
"prepublishOnly": "npm run build:lib",
"prepublishOnly": "npm run build",
"release": "pnpm publish --no-git-checks"
},
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions packages/vite-plugin-combine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-combine",
"version": "6.1.2",
"version": "6.1.3",
"description": "Combines multiple module files into a single target file. It supports four modes: named exports, default exports, automatic exports, and no exports, and can auto-generate corresponding import statements based on configuration.",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
Expand All @@ -17,9 +17,9 @@
"vite": ">=3.1.0"
},
"scripts": {
"build:lib": "vite build",
"build": "vite build",
"watch": "vite build --watch",
"prepublishOnly": "npm run build:lib",
"prepublishOnly": "npm run build",
"release": "pnpm publish --no-git-checks"
},
"repository": {
Expand Down
1 change: 1 addition & 0 deletions packages/vite-plugin-combine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export default function pluginCombine(opts: Options) {
return {
name: PLUGIN_NAME,
enforce: ('enforce' in opts) ? opts.enforce : 'post',
apply: ('apply' in opts) ? opts.apply : 'build',

async config(config) {
const inputs = files.concat(absTarget);
Expand Down
8 changes: 8 additions & 0 deletions packages/vite-plugin-combine/src/typings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { NullValue } from 'rollup';
import type { ConfigEnv, UserConfig } from 'vite';
import type { LogLevel } from 'vp-runtime-helper';

export type { LogLevel };
Expand Down Expand Up @@ -44,6 +45,13 @@ export interface Options {
*/
enforce?: 'pre' | 'post';

/**
* Apply the plugin only for serve or build, or on certain conditions.
*
* 应用插件仅在 serve 或 build 时,或满足某些条件的情况下。
*/
apply?: 'serve' | 'build' | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);

/**
* Current Working Directory.
*
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-cp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"vite": ">=3.1.0"
},
"scripts": {
"build:lib": "vite build",
"build": "vite build",
"watch": "vite build --watch",
"prepublishOnly": "npm run build:lib",
"prepublishOnly": "npm run build",
"release": "pnpm publish --no-git-checks"
},
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions packages/vite-plugin-external/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
}
},
"scripts": {
"build:lib": "vite build",
"build": "vite build",
"watch": "vite build --watch",
"prepublishOnly": "npm run build:lib",
"prepublishOnly": "npm run build",
"release": "pnpm publish --no-git-checks"
},
"engines": {
Expand All @@ -40,7 +40,7 @@
"homepage": "https://fengxinming.github.io/vite-plugins/plugins/vite-plugin-external/quick-start",
"dependencies": {
"fs-extra": "^11.1.1",
"is-what-type": "^1.1.0",
"is-what-type": "^1.1.1",
"vp-runtime-helper": "workspace:^"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-hook-use/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"vite": ">=3.1.0"
},
"scripts": {
"build:lib": "vite build",
"build": "vite build",
"watch": "vite build --watch",
"prepublishOnly": "npm run build:lib",
"prepublishOnly": "npm run build",
"release": "pnpm publish --no-git-checks"
},
"repository": {
Expand Down
Loading