Skip to content

Commit 87884b3

Browse files
committed
💚 增加iife的输出,完善文档与demo
1 parent 5e116b3 commit 87884b3

5 files changed

Lines changed: 40 additions & 25 deletions

File tree

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,42 @@
22

33
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/owner/my-element)
44

5+
## DEMO
6+
7+
- [example 1](https://bioforestchain.github.io/virtual-scroll/)
8+
59
## Usage
610

11+
**Install Dep**
12+
713
```bash
814
npm i @bfchain/virtual-scroll --save
915
yarn add @bfchain/virtual-scroll
1016
```
1117

18+
**moderns web dev**
19+
20+
> For Angular/React/Vue/Preact etc.
21+
1222
```ts
1323
import "@bfchain/virtual-scroll";
1424
```
1525

16-
## DEMO
26+
**or include directly**
27+
28+
> For vanillajs
29+
30+
```html
31+
<script src="./node_modules/@bfchain/virtual-scroll/dist/vitrual-scroll.iife.js"></script>
32+
```
33+
34+
**then you can use the component in your html**
1735

1836
<!--
1937
```html
20-
<custom-element-demo>
38+
<custom-element-demo height="640">
2139
<template>
22-
<script type="importmap">
23-
{
24-
"imports": {
25-
"lit-element": "//unpkg.com/lit-element@2.4.0/lit-element.js",
26-
"lit-html/": "//unpkg.com/lit-html@1.4.1/"
27-
}
28-
}
29-
</script>
30-
<script type="module" src="./dist/virtual-scroll.es.js"></script>
40+
<script type="module" src="./iife/virtual-scroll.iife.js"></script>
3141
<style>
3242
html,
3343
body {

demo.html

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
<script type="importmap">
2-
{
3-
"imports": {
4-
"lit-element": "//unpkg.com/lit-element@2.4.0/lit-element.js",
5-
"lit-html/": "//unpkg.com/lit-html@1.4.1/"
6-
}
7-
}
8-
</script>
9-
<script type="module" src="./dist/virtual-scroll.es.js"></script>
1+
<script type="module" src="./dist/virtual-scroll.iife.js"></script>
102
<style>
113
html,
124
body {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@bfchain/virtual-scroll",
3-
"version": "1.4.0",
4-
"main": "dist/virtual-scroll.cjs.js",
3+
"version": "1.4.1",
4+
"main": "./dist/virtual-scroll.iife.js",
55
"exports": {
66
".": {
77
"import": "./dist/virtual-scroll.es.js",
@@ -21,7 +21,7 @@
2121
"scripts": {
2222
"dev": "vite --host 0.0.0.0 --port 4600",
2323
"publ": "npm publ --access public",
24-
"build": "tsc && vite build && vite build -c .\\vite-demo.config.ts --base=./",
24+
"build": "tsc && vite build && vite build -c .\\vite-iife.config.ts && vite build -c .\\vite-demo.config.ts --base=./",
2525
"vite": "vite"
2626
},
2727
"dependencies": {

vite-iife.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from "vite";
2+
3+
// https://vitejs.dev/config/
4+
export default defineConfig({
5+
build: {
6+
target: ["chrome74"],
7+
lib: {
8+
entry: "src/index.ts",
9+
name: "virtualScroll",
10+
formats: ["iife"],
11+
},
12+
emptyOutDir: false,
13+
},
14+
});

vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ export default defineConfig({
66
target: ["chrome74"],
77
lib: {
88
entry: "src/index.ts",
9-
name: "virtualScroll",
10-
formats: ["es", "cjs", "umd"],
9+
formats: ["es", "cjs"],
1110
},
1211
rollupOptions: {
1312
external: /^lit-element/,

0 commit comments

Comments
 (0)