Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lvyjs/core

为 nodejs 开发而设计的打包构建工具
https://github.com/lvyjs/core

esbuild lvyjs nodejs puppeteer rollup tsx

Last synced: 20 days ago
JSON representation

为 nodejs 开发而设计的打包构建工具

Awesome Lists containing this project

README

        

# LVY

为 nodejs 开发而设计的打包构建工具

| Project | Status | Description |
| ------- | --------------------- | ----------- |
| [lvyjs] | [![lvyjs-s]][lvyjs-p] | 打包工具 |

[lvyjs]: https://github.com/lemonade-lab/alemonjs/tree/main/packages/lvyjs
[lvyjs-s]: https://img.shields.io/npm/v/lvyjs.svg
[lvyjs-p]: https://www.npmjs.com/package/lvyjs

- use

```sh
npm install lvyjs -D
```

- tsconfig.json

```json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@src/*": ["src/*"]
}
},
"include": ["src/**/*"],
"extends": "lvyjs/tsconfig.json"
}
```

- lvy.config.ts

```ts
import { defineConfig } from 'lvyjs'
import { fileURLToPath } from 'url'
import { dirname, join } from 'path'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
export default defineConfig({
plugins: [
{
name: 'lvy-test-app',
useApp: () => import('./src/index')
}
],
build: {
alias: {
entries: [{ find: '@src', replacement: join(__dirname, 'src') }]
}
}
})
```

```sh
npx lvy dev
```

- 装载

> src/index.ts

```ts
import { readFileSync } from 'fs'
// 得到该文件的绝对路径,类型 string
import img_logo from '../logo.png'
const data = readFileSync(img_logo, 'utf-8')
```

- 别名

> src/index.ts

```ts
import { readFileSync } from 'fs'
// 得到该文件的绝对路径,类型 string
import img_logo from '@src/asstes/img/logo.png'
const data = readFileSync(img_logo, 'utf-8')
```

- 打包

> 对 src 目录打包并输出到 lib 目录

```sh
npx lvy build
```