@varlet/cli 3.2.5 → 3.2.6-alpha.1713972861390
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/README.md +1 -0
- package/README.zh-CN.md +2 -1
- package/lib/node/compiler/compileModule.js +4 -2
- package/lib/node/compiler/compileSFC.js +5 -2
- package/lib/node/compiler/compileScript.d.ts +3 -1
- package/lib/node/compiler/compileScript.js +38 -18
- package/lib/node/compiler/compileStyle.d.ts +5 -1
- package/lib/node/compiler/compileStyle.js +34 -7
- package/lib/node/config/varlet.config.d.ts +1 -0
- package/lib/node/config/vite.config.js +10 -3
- package/lib/node/shared/constant.js +1 -1
- package/lib/node/shared/fsUtils.d.ts +1 -0
- package/lib/node/shared/fsUtils.js +1 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ Also refer to `@varlet/ui` [varlet.config.mjs](https://github.com/varletjs/varle
|
|
|
47
47
|
| `port` | Development server port | _number_ | `8080` |
|
|
48
48
|
| `title` | The title of the component library in the document | _string_ | `VARLET` |
|
|
49
49
|
| `logo` | The logo of the component library in the document | _string_ | `-` |
|
|
50
|
+
| `alias` | Path alias (root is src folder when use relative path) | _Record<string, string>_ | `-` |
|
|
50
51
|
| `defaultLanguage` | Document default language | _string_ | `zh-CN` |
|
|
51
52
|
| `defaultLightTheme` | The default light theme | _string_ | `md3LightTheme` |
|
|
52
53
|
| `defaultDarkTheme` | The default dark theme | _string_ | `md3DarkTheme` |
|
package/README.zh-CN.md
CHANGED
|
@@ -46,7 +46,8 @@ varlet-cli gen
|
|
|
46
46
|
| `host` | 开发服务器主机 | _number_ | `localhost` |
|
|
47
47
|
| `port` | 开发服务器端口 | _number_ | `8080` |
|
|
48
48
|
| `title` | 文档中组件库的标题 | _string_ | `VARLET` |
|
|
49
|
-
| `logo` | 文档中组件库的logo | _string_ | `-` |
|
|
49
|
+
| `logo` | 文档中组件库的 logo | _string_ | `-` |
|
|
50
|
+
| `alias` | 路径别名 (使用相对路径时,根路径为 src 文件夹) | _Record<string, string>_ | `-` |
|
|
50
51
|
| `defaultLanguage` | 文档默认语言 | _string_ | `zh-CN` |
|
|
51
52
|
| `defaultLightTheme` | 默认的亮色主题 | _string_ | `md3LightTheme` |
|
|
52
53
|
| `defaultDarkTheme` | 默认的暗色主题 | _string_ | `md3DarkTheme` |
|
|
@@ -2,10 +2,10 @@ import fse from 'fs-extra';
|
|
|
2
2
|
import { build } from 'vite';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { EXAMPLE_DIR_NAME, TESTS_DIR_NAME, DOCS_DIR_NAME, SRC_DIR, ES_DIR, STYLE_DIR_NAME, LIB_DIR, UMD_DIR, } from '../shared/constant.js';
|
|
5
|
-
import { getPublicDirs, isDir, isDTS, isLess, isScript, isSFC } from '../shared/fsUtils.js';
|
|
5
|
+
import { getPublicDirs, isDir, isDTS, isLess, isScript, isScss, isSFC } from '../shared/fsUtils.js';
|
|
6
6
|
import { compileSFC } from './compileSFC.js';
|
|
7
7
|
import { compileESEntry, compileScriptFile, getScriptExtname } from './compileScript.js';
|
|
8
|
-
import { clearLessFiles, compileLess } from './compileStyle.js';
|
|
8
|
+
import { clearLessFiles, clearScssFiles, compileLess, compileScss } from './compileStyle.js';
|
|
9
9
|
import { getBundleConfig } from '../config/vite.config.js';
|
|
10
10
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
11
11
|
import { generateReference } from './compileTypes.js';
|
|
@@ -56,6 +56,7 @@ export async function compileFile(file) {
|
|
|
56
56
|
isSFC(file) && (await compileSFC(file));
|
|
57
57
|
isScript(file) && (await compileScriptFile(file));
|
|
58
58
|
isLess(file) && (await compileLess(file));
|
|
59
|
+
isScss(file) && compileScss(file);
|
|
59
60
|
isDir(file) && (await compileDir(file));
|
|
60
61
|
}
|
|
61
62
|
export async function compileModule() {
|
|
@@ -70,5 +71,6 @@ export async function compileModule() {
|
|
|
70
71
|
const publicDirs = await getPublicDirs();
|
|
71
72
|
await compileESEntry(dest, publicDirs);
|
|
72
73
|
clearLessFiles(dest);
|
|
74
|
+
clearScssFiles(dest);
|
|
73
75
|
generateReference(dest);
|
|
74
76
|
}
|
|
@@ -6,7 +6,7 @@ import { replaceExt, smartAppendFileSync } from '../shared/fsUtils.js';
|
|
|
6
6
|
import { SRC_DIR, ES_DIR } from '../shared/constant.js';
|
|
7
7
|
import { compileScript, getScriptExtname } from './compileScript.js';
|
|
8
8
|
import ts from 'typescript';
|
|
9
|
-
import {
|
|
9
|
+
import { compressCss, compileLess, compileScss, extractStyleDependencies, normalizeStyleDependency, STYLE_IMPORT_RE, } from './compileStyle.js';
|
|
10
10
|
const { readFile, existsSync, readFileSync, writeFileSync } = fse;
|
|
11
11
|
registerTS(() => ts);
|
|
12
12
|
const EXPORT = 'export default';
|
|
@@ -98,10 +98,13 @@ export async function compileSFC(sfc) {
|
|
|
98
98
|
scoped: style.scoped,
|
|
99
99
|
});
|
|
100
100
|
code = extractStyleDependencies(file, code, STYLE_IMPORT_RE);
|
|
101
|
-
writeFileSync(file,
|
|
101
|
+
writeFileSync(file, compressCss(code), 'utf-8');
|
|
102
102
|
smartAppendFileSync(cssFile, `import '${dependencyPath}.css'\n`);
|
|
103
103
|
if (style.lang === 'less') {
|
|
104
104
|
await compileLess(file);
|
|
105
105
|
}
|
|
106
|
+
if (style.lang === 'scss') {
|
|
107
|
+
compileScss(file);
|
|
108
|
+
}
|
|
106
109
|
}
|
|
107
110
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VarletConfig } from '../config/varlet.config.js';
|
|
1
2
|
export declare const IMPORT_FROM_DEPENDENCE_RE: RegExp;
|
|
2
3
|
export declare const EXPORT_FROM_DEPENDENCE_RE: RegExp;
|
|
3
4
|
export declare const IMPORT_DEPENDENCE_RE: RegExp;
|
|
@@ -6,7 +7,8 @@ export declare const styleExtNames: string[];
|
|
|
6
7
|
export declare const scriptIndexes: string[];
|
|
7
8
|
export declare const styleIndexes: string[];
|
|
8
9
|
export declare const tryMatchExtname: (file: string, extname: string[]) => string | undefined;
|
|
9
|
-
export declare const
|
|
10
|
+
export declare const resolveAlias: (dependence: string, file: string, alias?: VarletConfig['alias']) => string;
|
|
11
|
+
export declare const resolveDependence: (file: string, script: string, alias?: VarletConfig['alias']) => string;
|
|
10
12
|
export declare function compileScriptByBabel(script: string, file: string): Promise<string>;
|
|
11
13
|
export declare function compileScriptByEsbuild(script: string): Promise<string>;
|
|
12
14
|
export declare function compileScript(script: string, file: string): Promise<void>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import esbuild from 'esbuild';
|
|
1
|
+
import { ES_DIR } from '../shared/constant.js';
|
|
3
2
|
import { transformAsync } from '@babel/core';
|
|
4
3
|
import { bigCamelize } from '@varlet/shared';
|
|
5
4
|
import { getVersion, isDir, isJsx, isTsx, replaceExt } from '../shared/fsUtils.js';
|
|
6
|
-
import { extractStyleDependencies, IMPORT_CSS_RE, IMPORT_LESS_RE } from './compileStyle.js';
|
|
7
|
-
import { resolve, extname, dirname } from 'path';
|
|
5
|
+
import { extractStyleDependencies, IMPORT_CSS_RE, IMPORT_LESS_RE, IMPORT_SCSS_RE } from './compileStyle.js';
|
|
6
|
+
import { resolve, relative, extname, dirname } from 'path';
|
|
8
7
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
9
8
|
import { get } from 'lodash-es';
|
|
9
|
+
import fse from 'fs-extra';
|
|
10
|
+
import esbuild from 'esbuild';
|
|
10
11
|
const { writeFileSync, readdirSync, readFileSync, removeSync, writeFile, pathExistsSync } = fse;
|
|
11
12
|
// https://regexr.com/765a4
|
|
12
13
|
export const IMPORT_FROM_DEPENDENCE_RE = /import\s+?[\w\s{},$*]+\s+from\s+?(".*?"|'.*?')/g;
|
|
@@ -15,9 +16,9 @@ export const EXPORT_FROM_DEPENDENCE_RE = /export\s+?[\w\s{},$*]+\s+from\s+?(".*?
|
|
|
15
16
|
// https://regexr.com/764ve
|
|
16
17
|
export const IMPORT_DEPENDENCE_RE = /import\s+(".*?"|'.*?')/g;
|
|
17
18
|
export const scriptExtNames = ['.vue', '.ts', '.tsx', '.mjs', '.js', '.jsx'];
|
|
18
|
-
export const styleExtNames = ['.less', '.css'];
|
|
19
|
+
export const styleExtNames = ['.less', '.scss', '.css'];
|
|
19
20
|
export const scriptIndexes = ['index.mjs', 'index.vue', 'index.ts', 'index.tsx', 'index.js', 'index.jsx'];
|
|
20
|
-
export const styleIndexes = ['index.less', 'index.css'];
|
|
21
|
+
export const styleIndexes = ['index.less', 'index.scss', 'index.css'];
|
|
21
22
|
export const tryMatchExtname = (file, extname) => {
|
|
22
23
|
// eslint-disable-next-line no-restricted-syntax
|
|
23
24
|
for (const ext of extname) {
|
|
@@ -27,18 +28,34 @@ export const tryMatchExtname = (file, extname) => {
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
|
-
export const
|
|
31
|
+
export const resolveAlias = (dependence, file, alias = {}) => {
|
|
32
|
+
let matchedAliasKey = Object.keys(alias).find((key) => dependence === key);
|
|
33
|
+
if (!matchedAliasKey) {
|
|
34
|
+
// @/ -> yes
|
|
35
|
+
// @varlet/ui -> no
|
|
36
|
+
matchedAliasKey = Object.keys(alias).find((key) => dependence.startsWith(`${key}/`));
|
|
37
|
+
}
|
|
38
|
+
if (!matchedAliasKey) {
|
|
39
|
+
return dependence;
|
|
40
|
+
}
|
|
41
|
+
const matchedAliasValue = alias[matchedAliasKey];
|
|
42
|
+
const isRelative = matchedAliasValue.startsWith('.');
|
|
43
|
+
const replacedValue = isRelative ? relative(dirname(file), resolve(ES_DIR, matchedAliasValue)) : matchedAliasValue;
|
|
44
|
+
return dependence.replace(matchedAliasKey, replacedValue);
|
|
45
|
+
};
|
|
46
|
+
export const resolveDependence = (file, script, alias = {}) => {
|
|
31
47
|
const replacer = (source, dependence) => {
|
|
48
|
+
// remove quotes
|
|
32
49
|
dependence = dependence.slice(1, dependence.length - 1);
|
|
33
|
-
const ext = extname(dependence);
|
|
34
|
-
const targetDependenceFile = resolve(dirname(file), dependence);
|
|
35
|
-
const scriptExtname = getScriptExtname();
|
|
36
|
-
const inNodeModules = !dependence.startsWith('.');
|
|
37
50
|
const done = (targetDependence) => source.replace(dependence, targetDependence);
|
|
38
|
-
|
|
51
|
+
const resolvedDependence = resolveAlias(dependence, file, alias);
|
|
52
|
+
const isNodeModule = !resolvedDependence.startsWith('.');
|
|
53
|
+
if (isNodeModule) {
|
|
39
54
|
// e.g. @varlet/shared
|
|
40
|
-
return
|
|
55
|
+
return done(resolvedDependence);
|
|
41
56
|
}
|
|
57
|
+
const ext = extname(resolvedDependence);
|
|
58
|
+
const scriptExtname = getScriptExtname();
|
|
42
59
|
if (ext) {
|
|
43
60
|
if (scriptExtNames.includes(ext)) {
|
|
44
61
|
// e.g. './a.vue' -> './a.mjs'
|
|
@@ -49,15 +66,16 @@ export const resolveDependence = (file, script) => {
|
|
|
49
66
|
return source;
|
|
50
67
|
}
|
|
51
68
|
}
|
|
69
|
+
const targetDependenceFile = resolve(dirname(file), resolvedDependence);
|
|
52
70
|
if (!ext) {
|
|
53
71
|
// e.g. ../button/props -> ../button/props.mjs
|
|
54
72
|
const matchedScript = tryMatchExtname(targetDependenceFile, scriptExtNames);
|
|
55
73
|
if (matchedScript) {
|
|
56
|
-
return done(`${
|
|
74
|
+
return done(`${resolvedDependence}${scriptExtname}`);
|
|
57
75
|
}
|
|
58
76
|
const matchedStyle = tryMatchExtname(targetDependenceFile, styleExtNames);
|
|
59
77
|
if (matchedStyle) {
|
|
60
|
-
return done(`${
|
|
78
|
+
return done(`${resolvedDependence}${matchedStyle}`);
|
|
61
79
|
}
|
|
62
80
|
}
|
|
63
81
|
if (!ext && isDir(targetDependenceFile)) {
|
|
@@ -66,12 +84,12 @@ export const resolveDependence = (file, script) => {
|
|
|
66
84
|
const hasScriptIndex = files.some((file) => scriptIndexes.some((name) => file.endsWith(name)));
|
|
67
85
|
if (hasScriptIndex) {
|
|
68
86
|
// e.g. -> ../button/index.mjs
|
|
69
|
-
return done(`${
|
|
87
|
+
return done(`${resolvedDependence}/index${scriptExtname}`);
|
|
70
88
|
}
|
|
71
89
|
const hasStyleIndex = files.some((file) => styleIndexes.some((name) => file.endsWith(name)));
|
|
72
90
|
if (hasStyleIndex) {
|
|
73
91
|
// e.g. -> ../button/index.css
|
|
74
|
-
return done(`${
|
|
92
|
+
return done(`${resolvedDependence}/index.css`);
|
|
75
93
|
}
|
|
76
94
|
}
|
|
77
95
|
return '';
|
|
@@ -109,10 +127,12 @@ export async function compileScriptByEsbuild(script) {
|
|
|
109
127
|
export async function compileScript(script, file) {
|
|
110
128
|
let code = isJsx(file) || isTsx(file) ? await compileScriptByBabel(script, file) : script;
|
|
111
129
|
code = await compileScriptByEsbuild(code);
|
|
130
|
+
const { alias } = await getVarletConfig();
|
|
112
131
|
if (code) {
|
|
113
|
-
code = resolveDependence(file, code);
|
|
132
|
+
code = resolveDependence(file, code, alias);
|
|
114
133
|
code = extractStyleDependencies(file, code, IMPORT_CSS_RE);
|
|
115
134
|
code = extractStyleDependencies(file, code, IMPORT_LESS_RE);
|
|
135
|
+
code = extractStyleDependencies(file, code, IMPORT_SCSS_RE);
|
|
116
136
|
}
|
|
117
137
|
removeSync(file);
|
|
118
138
|
writeFileSync(replaceExt(file, getScriptExtname()), code, 'utf8');
|
|
@@ -2,9 +2,13 @@ export declare const EMPTY_SPACE_RE: RegExp;
|
|
|
2
2
|
export declare const EMPTY_LINE_RE: RegExp;
|
|
3
3
|
export declare const IMPORT_CSS_RE: RegExp;
|
|
4
4
|
export declare const IMPORT_LESS_RE: RegExp;
|
|
5
|
+
export declare const IMPORT_SCSS_RE: RegExp;
|
|
6
|
+
export declare const STYLE_EXTNAME_RE: RegExp;
|
|
5
7
|
export declare const STYLE_IMPORT_RE: RegExp;
|
|
6
|
-
export declare const
|
|
8
|
+
export declare const compressCss: (s: string) => string;
|
|
7
9
|
export declare function normalizeStyleDependency(styleImport: string, reg: RegExp): string;
|
|
8
10
|
export declare function extractStyleDependencies(file: string, code: string, styleReg: RegExp): string;
|
|
9
11
|
export declare function compileLess(file: string): Promise<void>;
|
|
12
|
+
export declare function compileScss(file: string): void;
|
|
10
13
|
export declare function clearLessFiles(dir: string): void;
|
|
14
|
+
export declare function clearScssFiles(dir: string): void;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
2
|
import less from 'less';
|
|
3
|
+
import sass from 'node-sass';
|
|
3
4
|
import glob from 'glob';
|
|
4
5
|
import { replaceExt, smartAppendFileSync } from '../shared/fsUtils.js';
|
|
5
6
|
import { parse, resolve } from 'path';
|
|
6
7
|
import { getScriptExtname } from './compileScript.js';
|
|
7
8
|
import { CWD } from '../shared/constant.js';
|
|
8
|
-
|
|
9
|
+
import { createRequire } from 'module';
|
|
10
|
+
const { render: renderLess } = less;
|
|
11
|
+
const { renderSync: renderScss } = sass;
|
|
9
12
|
const { readFileSync, writeFileSync, unlinkSync } = fse;
|
|
13
|
+
const require = createRequire(import.meta.url);
|
|
10
14
|
export const EMPTY_SPACE_RE = /[\s]+/g;
|
|
11
15
|
export const EMPTY_LINE_RE = /[\n\r]*/g;
|
|
12
16
|
export const IMPORT_CSS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.css)['"]\s*;?(?!\s*['"`])/g;
|
|
13
17
|
export const IMPORT_LESS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.less)['"]\s*;?(?!\s*['"`])/g;
|
|
18
|
+
export const IMPORT_SCSS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.scss)['"]\s*;?(?!\s*['"`])/g;
|
|
19
|
+
export const STYLE_EXTNAME_RE = /(\.less)|(\.scss)|(\.css)/;
|
|
14
20
|
export const STYLE_IMPORT_RE = /@import\s+['"](.+)['"]\s*;/g;
|
|
15
|
-
export const
|
|
21
|
+
export const compressCss = (s) => s.replace(EMPTY_LINE_RE, '').replace(EMPTY_SPACE_RE, ' ');
|
|
16
22
|
export function normalizeStyleDependency(styleImport, reg) {
|
|
17
23
|
let relativePath = styleImport.replace(reg, '$1');
|
|
18
|
-
relativePath = relativePath.replace(
|
|
24
|
+
relativePath = relativePath.replace(STYLE_EXTNAME_RE, '');
|
|
19
25
|
if (relativePath.startsWith('./')) {
|
|
20
26
|
return '.' + relativePath;
|
|
21
27
|
}
|
|
@@ -32,13 +38,34 @@ export function extractStyleDependencies(file, code, styleReg) {
|
|
|
32
38
|
}
|
|
33
39
|
export async function compileLess(file) {
|
|
34
40
|
const source = readFileSync(file, 'utf-8');
|
|
35
|
-
const { css } = await
|
|
41
|
+
const { css } = await renderLess(source, {
|
|
36
42
|
filename: file,
|
|
37
43
|
paths: [resolve(CWD, 'node_modules')],
|
|
38
44
|
});
|
|
39
|
-
writeFileSync(replaceExt(file, '.css'),
|
|
45
|
+
writeFileSync(replaceExt(file, '.css'), compressCss(css), 'utf-8');
|
|
46
|
+
}
|
|
47
|
+
export function compileScss(file) {
|
|
48
|
+
const source = readFileSync(file, 'utf-8');
|
|
49
|
+
const { css } = renderScss({
|
|
50
|
+
data: source,
|
|
51
|
+
file,
|
|
52
|
+
importer(path) {
|
|
53
|
+
if (!path.endsWith('.scss') || !path.endsWith('.css')) {
|
|
54
|
+
path += '.scss';
|
|
55
|
+
}
|
|
56
|
+
if (path.startsWith('~')) {
|
|
57
|
+
path = path.replace('~', '');
|
|
58
|
+
path = require.resolve(path);
|
|
59
|
+
}
|
|
60
|
+
return { file: path };
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
console.log(css.toString('utf8'));
|
|
64
|
+
writeFileSync(replaceExt(file, '.css'), compressCss(css.toString('utf8')), 'utf-8');
|
|
40
65
|
}
|
|
41
66
|
export function clearLessFiles(dir) {
|
|
42
|
-
|
|
43
|
-
|
|
67
|
+
glob.sync(`${dir}/**/*.less`).forEach(unlinkSync);
|
|
68
|
+
}
|
|
69
|
+
export function clearScssFiles(dir) {
|
|
70
|
+
glob.sync(`${dir}/**/*.scss`).forEach(unlinkSync);
|
|
44
71
|
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import jsx from '@vitejs/plugin-vue-jsx';
|
|
1
|
+
import { SRC_DIR, ES_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, VITE_RESOLVE_EXTENSIONS, EXTENSION_ENTRY, } from '../shared/constant.js';
|
|
3
2
|
import { markdown, html, inlineCss, copy } from '@varlet/vite-plugins';
|
|
4
|
-
import { ES_DIR, SITE_CONFIG, SITE_DIR, SITE_MOBILE_ROUTES, SITE_OUTPUT_PATH, SITE_PC_ROUTES, SITE_PUBLIC_PATH, VITE_RESOLVE_EXTENSIONS, EXTENSION_ENTRY, } from '../shared/constant.js';
|
|
5
3
|
import { get } from 'lodash-es';
|
|
6
4
|
import { resolve } from 'path';
|
|
5
|
+
import vue from '@vitejs/plugin-vue';
|
|
6
|
+
import jsx from '@vitejs/plugin-vue-jsx';
|
|
7
7
|
export function getDevConfig(varletConfig) {
|
|
8
8
|
const defaultLanguage = get(varletConfig, 'defaultLanguage');
|
|
9
|
+
const alias = get(varletConfig, 'alias', {});
|
|
9
10
|
const host = get(varletConfig, 'host');
|
|
11
|
+
const resolveAlias = Object.entries(alias).reduce((resolveAlias, [key, value]) => {
|
|
12
|
+
const isRelative = value.startsWith('.');
|
|
13
|
+
resolveAlias[key] = isRelative ? resolve(SRC_DIR, value) : value;
|
|
14
|
+
return resolveAlias;
|
|
15
|
+
}, {});
|
|
10
16
|
return {
|
|
11
17
|
root: SITE_DIR,
|
|
12
18
|
resolve: {
|
|
13
19
|
extensions: VITE_RESOLVE_EXTENSIONS,
|
|
14
20
|
alias: {
|
|
21
|
+
...resolveAlias,
|
|
15
22
|
'@config': SITE_CONFIG,
|
|
16
23
|
'@pc-routes': SITE_PC_ROUTES,
|
|
17
24
|
'@mobile-routes': SITE_MOBILE_ROUTES,
|
|
@@ -13,7 +13,7 @@ export const TYPES_DIR = resolve(CWD, 'types');
|
|
|
13
13
|
export const ROOT_DOCS_DIR = resolve(CWD, 'docs');
|
|
14
14
|
export const ROOT_PAGES_DIR = resolve(CWD, 'pages');
|
|
15
15
|
export const ESLINT_EXTENSIONS = ['.vue', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs'];
|
|
16
|
-
export const VITE_RESOLVE_EXTENSIONS = ['.vue', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.less', '.css'];
|
|
16
|
+
export const VITE_RESOLVE_EXTENSIONS = ['.vue', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs', '.less', '.scss', '.css'];
|
|
17
17
|
export const SCRIPTS_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.cjs'];
|
|
18
18
|
export const PUBLIC_DIR_INDEXES = ['index.vue', 'index.tsx', 'index.ts', 'index.jsx', 'index.js'];
|
|
19
19
|
export const STYLE_DIR_NAME = 'style';
|
|
@@ -7,6 +7,7 @@ export declare const isJsx: (file: string) => boolean;
|
|
|
7
7
|
export declare const isTsx: (file: string) => boolean;
|
|
8
8
|
export declare const isScript: (file: string) => boolean;
|
|
9
9
|
export declare const isLess: (file: string) => boolean;
|
|
10
|
+
export declare const isScss: (file: string) => boolean;
|
|
10
11
|
export declare const isPublicDir: (dir: string) => boolean;
|
|
11
12
|
export declare const replaceExt: (file: string, ext: string) => string;
|
|
12
13
|
export declare function smartAppendFileSync(file: string, code: string): void;
|
|
@@ -16,6 +16,7 @@ export const isJsx = (file) => pathExistsSync(file) && file.endsWith('.jsx');
|
|
|
16
16
|
export const isTsx = (file) => pathExistsSync(file) && file.endsWith('.tsx');
|
|
17
17
|
export const isScript = (file) => pathExistsSync(file) && SCRIPTS_EXTENSIONS.includes(extname(file));
|
|
18
18
|
export const isLess = (file) => pathExistsSync(file) && extname(file) === '.less';
|
|
19
|
+
export const isScss = (file) => pathExistsSync(file) && extname(file) === '.scss';
|
|
19
20
|
export const isPublicDir = (dir) => PUBLIC_DIR_INDEXES.some((index) => pathExistsSync(resolve(dir, index)));
|
|
20
21
|
export const replaceExt = (file, ext) => file.replace(extname(file), ext);
|
|
21
22
|
export function smartAppendFileSync(file, code) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6-alpha.1713972861390",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@varlet/release": "^0.2.5",
|
|
38
|
-
"@varlet/icon-builder": "0.0.
|
|
38
|
+
"@varlet/icon-builder": "0.0.4",
|
|
39
39
|
"@babel/core": "^7.22.5",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@vitejs/plugin-vue": "5.0.4",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"hash-sum": "^2.0.0",
|
|
57
57
|
"inquirer": "^9.1.4",
|
|
58
58
|
"less": "^3.12.2",
|
|
59
|
+
"node-sass": "9.0.0",
|
|
59
60
|
"lodash-es": "^4.17.21",
|
|
60
61
|
"markdown-it": "^12.2.3",
|
|
61
62
|
"nanospinner": "^1.1.0",
|
|
@@ -64,8 +65,8 @@
|
|
|
64
65
|
"sharp": "0.31.1",
|
|
65
66
|
"slash": "^3.0.0",
|
|
66
67
|
"typescript": "^5.1.5",
|
|
67
|
-
"@varlet/shared": "3.2.
|
|
68
|
-
"@varlet/vite-plugins": "3.2.
|
|
68
|
+
"@varlet/shared": "3.2.6-alpha.1713972861390",
|
|
69
|
+
"@varlet/vite-plugins": "3.2.6-alpha.1713972861390"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@types/babel__core": "^7.20.1",
|
|
@@ -80,9 +81,9 @@
|
|
|
80
81
|
"@types/semver": "^7.3.9",
|
|
81
82
|
"@types/sharp": "0.31.1",
|
|
82
83
|
"rimraf": "^5.0.1",
|
|
83
|
-
"@varlet/
|
|
84
|
-
"@varlet/
|
|
85
|
-
"@varlet/touch-emulator": "3.2.
|
|
84
|
+
"@varlet/icons": "3.2.6-alpha.1713972861390",
|
|
85
|
+
"@varlet/ui": "3.2.6-alpha.1713972861390",
|
|
86
|
+
"@varlet/touch-emulator": "3.2.6-alpha.1713972861390"
|
|
86
87
|
},
|
|
87
88
|
"peerDependencies": {
|
|
88
89
|
"@vue/runtime-core": "3.4.21",
|
|
@@ -95,9 +96,9 @@
|
|
|
95
96
|
"lodash-es": "^4.17.21",
|
|
96
97
|
"vue": "3.4.21",
|
|
97
98
|
"vue-router": "4.2.0",
|
|
98
|
-
"@varlet/
|
|
99
|
-
"@varlet/
|
|
100
|
-
"@varlet/
|
|
99
|
+
"@varlet/ui": "3.2.6-alpha.1713972861390",
|
|
100
|
+
"@varlet/icons": "3.2.6-alpha.1713972861390",
|
|
101
|
+
"@varlet/touch-emulator": "3.2.6-alpha.1713972861390"
|
|
101
102
|
},
|
|
102
103
|
"scripts": {
|
|
103
104
|
"dev": "tsc --watch",
|