@varlet/cli 2.5.6 → 2.6.0-alpha.1673285309604
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/node/commands/lint.js +1 -1
- package/lib/node/config/vite.config.js +24 -43
- package/package.json +12 -13
|
@@ -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-
|
|
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
|
|
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,
|
|
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
|
-
|
|
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:
|
|
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: [
|
|
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.
|
|
3
|
+
"version": "2.6.0-alpha.1673285309604",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -40,10 +40,8 @@
|
|
|
40
40
|
"@babel/preset-env": "^7.14.8",
|
|
41
41
|
"@babel/preset-typescript": "^7.14.5",
|
|
42
42
|
"@types/inquirer": "^9.0.2",
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@vitejs/plugin-vue": "3.0.1",
|
|
46
|
-
"@vitejs/plugin-vue-jsx": "2.0.0",
|
|
43
|
+
"@vitejs/plugin-vue": "4.0.0",
|
|
44
|
+
"@vitejs/plugin-vue-jsx": "3.0.0",
|
|
47
45
|
"@vue/babel-plugin-jsx": "1.1.1",
|
|
48
46
|
"@vue/compiler-sfc": "3.2.25",
|
|
49
47
|
"@vue/runtime-core": "3.2.25",
|
|
@@ -66,10 +64,11 @@
|
|
|
66
64
|
"slash": "^3.0.0",
|
|
67
65
|
"ts-jest": "^26.5.1",
|
|
68
66
|
"typescript": "^4.4.4",
|
|
69
|
-
"vite": "
|
|
70
|
-
"vite-plugin-html": "^2.1.0",
|
|
67
|
+
"vite": "4.0.4",
|
|
71
68
|
"vue": "3.2.25",
|
|
72
|
-
"vue-jest": "^5.0.0-alpha.8"
|
|
69
|
+
"vue-jest": "^5.0.0-alpha.8",
|
|
70
|
+
"@varlet/vite-plugins": "2.6.0-alpha.1673285309604",
|
|
71
|
+
"@varlet/shared": "2.6.0-alpha.1673285309604"
|
|
73
72
|
},
|
|
74
73
|
"devDependencies": {
|
|
75
74
|
"@types/babel__core": "^7.1.12",
|
|
@@ -80,19 +79,19 @@
|
|
|
80
79
|
"@types/lodash-es": "^4.17.5",
|
|
81
80
|
"@types/node": "^18.7.20",
|
|
82
81
|
"@types/semver": "^7.3.9",
|
|
83
|
-
"@varlet/
|
|
84
|
-
"@varlet/
|
|
82
|
+
"@varlet/touch-emulator": "2.6.0-alpha.1673285309604",
|
|
83
|
+
"@varlet/icons": "2.6.0-alpha.1673285309604"
|
|
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-alpha.1673285309604",
|
|
94
|
+
"@varlet/touch-emulator": "2.6.0-alpha.1673285309604"
|
|
96
95
|
},
|
|
97
96
|
"scripts": {
|
|
98
97
|
"dev": "tsc --watch",
|