@varlet/vite-plugins 2.7.1 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/copy.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { Plugin } from 'vite';
2
+ export interface CopyPath {
3
+ from: string;
4
+ to: string;
5
+ type: 'folder' | 'file';
6
+ }
7
+ export interface CopyOptions {
8
+ paths: CopyPath[];
9
+ }
10
+ export declare function copy(options: CopyOptions): Plugin;
package/lib/copy.js ADDED
@@ -0,0 +1,18 @@
1
+ import fse from 'fs-extra';
2
+ const { copySync, copyFileSync } = fse;
3
+ export function copy(options) {
4
+ return {
5
+ name: 'vite-plugin-varlet-copy',
6
+ buildStart() {
7
+ options.paths.forEach((copyPath) => {
8
+ try {
9
+ ;
10
+ (copyPath.type === 'folder' ? copySync : copyFileSync)(copyPath.from, copyPath.to);
11
+ }
12
+ catch (e) {
13
+ this.warn(e);
14
+ }
15
+ });
16
+ },
17
+ };
18
+ }
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './markdown.js';
2
2
  export * from './html.js';
3
3
  export * from './inlineCss.js';
4
+ export * from './copy.js';
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './markdown.js';
2
2
  export * from './html.js';
3
3
  export * from './inlineCss.js';
4
+ export * from './copy.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/vite-plugins",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "type": "module",
5
5
  "description": "vite plugins of varlet",
6
6
  "main": "lib/index.js",
@@ -25,7 +25,7 @@
25
25
  "fs-extra": "^9.0.1",
26
26
  "highlight.js": "^10.7.2",
27
27
  "markdown-it": "^12.2.3",
28
- "@varlet/shared": "2.7.1"
28
+ "@varlet/shared": "2.7.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "vite": "^4.0.4",
package/src/copy.ts ADDED
@@ -0,0 +1,30 @@
1
+ import type { Plugin } from 'vite'
2
+ import fse from 'fs-extra'
3
+
4
+ const { copySync, copyFileSync } = fse
5
+
6
+ export interface CopyPath {
7
+ from: string
8
+ to: string
9
+ type: 'folder' | 'file'
10
+ }
11
+
12
+ export interface CopyOptions {
13
+ paths: CopyPath[]
14
+ }
15
+
16
+ export function copy(options: CopyOptions): Plugin {
17
+ return {
18
+ name: 'vite-plugin-varlet-copy',
19
+
20
+ buildStart() {
21
+ options.paths.forEach((copyPath) => {
22
+ try {
23
+ ;(copyPath.type === 'folder' ? copySync : copyFileSync)(copyPath.from, copyPath.to)
24
+ } catch (e: any) {
25
+ this.warn(e)
26
+ }
27
+ })
28
+ },
29
+ }
30
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './markdown.js'
2
2
  export * from './html.js'
3
3
  export * from './inlineCss.js'
4
+ export * from './copy.js'