@varlet/cli 2.5.6 → 2.6.0

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.
@@ -21,7 +21,7 @@ export async function lint() {
21
21
  './packages/varlet-cli/src',
22
22
  './packages/varlet-ui/src',
23
23
  './packages/varlet-icons/lib',
24
- './packages/varlet-markdown-vite-plugin',
24
+ './packages/varlet-vite-plugins/src',
25
25
  './packages/varlet-touch-emulator',
26
26
  './packages/varlet-vscode-extension/src',
27
27
  ];
@@ -1,13 +1,12 @@
1
+ import fse from 'fs-extra';
1
2
  import vue from '@vitejs/plugin-vue';
2
- import md from '@varlet/markdown-vite-plugin';
3
3
  import jsx from '@vitejs/plugin-vue-jsx';
4
- import fse from 'fs-extra';
5
- import { injectHtml } from 'vite-plugin-html';
6
- import { CWD, ES_DIR, LIB_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, UMD_DIR, VITE_RESOLVE_EXTENSIONS, } from '../shared/constant.js';
7
- import { get } from 'lodash-es';
4
+ import { markdown, html, inlineCss } from '@varlet/vite-plugins';
8
5
  import { kebabCase } from '@varlet/shared';
6
+ import { ES_DIR, LIB_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, UMD_DIR, VITE_RESOLVE_EXTENSIONS, } from '../shared/constant.js';
7
+ import { get } from 'lodash-es';
9
8
  import { resolve } from 'path';
10
- const { copyFileSync, pathExistsSync, readFileSync, removeSync, writeFileSync } = fse;
9
+ const { copyFileSync, removeSync } = fse;
11
10
  export function getDevConfig(varletConfig) {
12
11
  const defaultLanguage = get(varletConfig, 'defaultLanguage');
13
12
  const host = get(varletConfig, 'host');
@@ -30,14 +29,14 @@ export function getDevConfig(varletConfig) {
30
29
  vue({
31
30
  include: [/\.vue$/, /\.md$/],
32
31
  }),
33
- md({ style: get(varletConfig, 'highlight.style') }),
34
32
  jsx(),
35
- injectHtml({
33
+ markdown({ style: get(varletConfig, 'highlight.style') }),
34
+ html({
36
35
  data: {
37
- pcTitle: get(varletConfig, `pc.title['${defaultLanguage}']`),
38
- mobileTitle: get(varletConfig, `mobile.title['${defaultLanguage}']`),
39
36
  logo: get(varletConfig, `logo`),
40
37
  baidu: get(varletConfig, `analysis.baidu`, ''),
38
+ pcTitle: get(varletConfig, `pc.title['${defaultLanguage}']`),
39
+ mobileTitle: get(varletConfig, `mobile.title['${defaultLanguage}']`),
41
40
  },
42
41
  }),
43
42
  ],
@@ -58,43 +57,14 @@ export function getBuildConfig(varletConfig) {
58
57
  },
59
58
  } });
60
59
  }
61
- function inlineCSS(fileName, dir) {
62
- return {
63
- name: 'varlet-inline-css-vite-plugin',
64
- apply: 'build',
65
- closeBundle() {
66
- const cssFile = resolve(dir, 'style.css');
67
- if (!pathExistsSync(cssFile)) {
68
- return;
69
- }
70
- const jsFile = resolve(dir, fileName);
71
- const cssCode = readFileSync(cssFile, 'utf-8');
72
- const jsCode = readFileSync(jsFile, 'utf-8');
73
- const injectCode = `;(function(){var style=document.createElement('style');style.type='text/css';\
74
- style.rel='stylesheet';style.appendChild(document.createTextNode(\`${cssCode.replace(/\\/g, '\\\\')}\`));\
75
- var head=document.querySelector('head');head.appendChild(style)})();`;
76
- writeFileSync(jsFile, `${injectCode}${jsCode}`);
77
- copyFileSync(cssFile, resolve(LIB_DIR, 'style.css'));
78
- removeSync(cssFile);
79
- },
80
- };
81
- }
82
- function clear() {
83
- return {
84
- name: 'varlet-clear-vite-plugin',
85
- apply: 'build',
86
- closeBundle() {
87
- removeSync(resolve(CWD, 'dist'));
88
- },
89
- };
90
- }
91
60
  export function getESMBundleConfig(varletConfig) {
92
61
  const name = get(varletConfig, 'name');
93
62
  const fileName = `${kebabCase(name)}.esm.js`;
94
63
  return {
95
64
  logLevel: 'silent',
96
65
  build: {
97
- emptyOutDir: true,
66
+ emptyOutDir: false,
67
+ copyPublicDir: false,
98
68
  lib: {
99
69
  name,
100
70
  formats: ['es'],
@@ -112,16 +82,18 @@ export function getESMBundleConfig(varletConfig) {
112
82
  },
113
83
  },
114
84
  },
115
- plugins: [clear()],
116
85
  };
117
86
  }
118
87
  export function getUMDConfig(varletConfig) {
119
88
  const name = get(varletConfig, 'name');
120
89
  const fileName = `${kebabCase(name)}.js`;
90
+ const jsFile = resolve(UMD_DIR, fileName);
91
+ const cssFile = resolve(UMD_DIR, 'style.css');
121
92
  return {
122
93
  logLevel: 'silent',
123
94
  build: {
124
95
  emptyOutDir: true,
96
+ copyPublicDir: false,
125
97
  lib: {
126
98
  name,
127
99
  formats: ['umd'],
@@ -139,6 +111,15 @@ export function getUMDConfig(varletConfig) {
139
111
  },
140
112
  },
141
113
  },
142
- plugins: [inlineCSS(fileName, UMD_DIR), clear()],
114
+ plugins: [
115
+ inlineCss({
116
+ jsFile,
117
+ cssFile,
118
+ onEnd() {
119
+ copyFileSync(cssFile, resolve(LIB_DIR, 'style.css'));
120
+ removeSync(cssFile);
121
+ },
122
+ }),
123
+ ],
143
124
  };
144
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.5.6",
3
+ "version": "2.6.0",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -39,11 +39,8 @@
39
39
  "@babel/helper-plugin-utils": "^7.14.5",
40
40
  "@babel/preset-env": "^7.14.8",
41
41
  "@babel/preset-typescript": "^7.14.5",
42
- "@types/inquirer": "^9.0.2",
43
- "@varlet/markdown-vite-plugin": "2.5.6",
44
- "@varlet/shared": "2.5.6",
45
- "@vitejs/plugin-vue": "3.0.1",
46
- "@vitejs/plugin-vue-jsx": "2.0.0",
42
+ "@vitejs/plugin-vue": "4.0.0",
43
+ "@vitejs/plugin-vue-jsx": "3.0.0",
47
44
  "@vue/babel-plugin-jsx": "1.1.1",
48
45
  "@vue/compiler-sfc": "3.2.25",
49
46
  "@vue/runtime-core": "3.2.25",
@@ -66,10 +63,11 @@
66
63
  "slash": "^3.0.0",
67
64
  "ts-jest": "^26.5.1",
68
65
  "typescript": "^4.4.4",
69
- "vite": "3.0.4",
70
- "vite-plugin-html": "^2.1.0",
66
+ "vite": "4.0.4",
71
67
  "vue": "3.2.25",
72
- "vue-jest": "^5.0.0-alpha.8"
68
+ "vue-jest": "^5.0.0-alpha.8",
69
+ "@varlet/vite-plugins": "2.6.0",
70
+ "@varlet/shared": "2.6.0"
73
71
  },
74
72
  "devDependencies": {
75
73
  "@types/babel__core": "^7.1.12",
@@ -80,19 +78,20 @@
80
78
  "@types/lodash-es": "^4.17.5",
81
79
  "@types/node": "^18.7.20",
82
80
  "@types/semver": "^7.3.9",
83
- "@varlet/icons": "2.5.6",
84
- "@varlet/touch-emulator": "2.5.6"
81
+ "@types/inquirer": "^9.0.2",
82
+ "@varlet/icons": "2.6.0",
83
+ "@varlet/touch-emulator": "2.6.0"
85
84
  },
86
85
  "peerDependencies": {
87
- "@varlet/icons": "2.5.6",
88
- "@varlet/touch-emulator": "2.5.6",
89
86
  "@vue/runtime-core": "3.2.16",
90
87
  "@vue/test-utils": "^2.0.2",
91
88
  "clipboard": "^2.0.6",
92
89
  "live-server": "^1.2.1",
93
90
  "lodash-es": "^4.17.21",
94
91
  "vue": "3.2.25",
95
- "vue-router": "4.0.12"
92
+ "vue-router": "4.0.12",
93
+ "@varlet/icons": "2.6.0",
94
+ "@varlet/touch-emulator": "2.6.0"
96
95
  },
97
96
  "scripts": {
98
97
  "dev": "tsc --watch",