@gct-paas/build 0.0.1-dev.8
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/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/commitlint/commitlint-config/commitlint-config.cjs +15 -0
- package/dist/commitlint/commitlint-config/commitlint-config.d.ts +9 -0
- package/dist/commitlint/index.cjs +12 -0
- package/dist/commitlint/index.d.ts +1 -0
- package/dist/constants/index.cjs +9 -0
- package/dist/constants/index.d.ts +12 -0
- package/dist/eslint/eslint-config/eslint-config.cjs +85 -0
- package/dist/eslint/eslint-config/eslint-config.d.ts +9 -0
- package/dist/eslint/index.cjs +12 -0
- package/dist/eslint/index.d.ts +1 -0
- package/dist/index.cjs +82 -0
- package/dist/index.d.ts +7 -0
- package/dist/prettier/index.cjs +12 -0
- package/dist/prettier/index.d.ts +1 -0
- package/dist/prettier/prettier-config/prettier-config.cjs +29 -0
- package/dist/prettier/prettier-config/prettier-config.d.ts +22 -0
- package/dist/rollup/index.cjs +27 -0
- package/dist/rollup/index.d.ts +2 -0
- package/dist/rollup/rollup-config/dev-config.cjs +93 -0
- package/dist/rollup/rollup-config/dev-config.d.ts +9 -0
- package/dist/rollup/rollup-plugins/copy-file.cjs +24 -0
- package/dist/rollup/rollup-plugins/copy-file.d.ts +37 -0
- package/dist/rollup/rollup-plugins/ignore-compiler-file.cjs +23 -0
- package/dist/rollup/rollup-plugins/ignore-compiler-file.d.ts +8 -0
- package/dist/rollup/rollup-plugins/index.cjs +19 -0
- package/dist/rollup/rollup-plugins/index.d.ts +2 -0
- package/dist/stylelint/index.cjs +12 -0
- package/dist/stylelint/index.d.ts +1 -0
- package/dist/stylelint/stylelint-config/stylelint-config.cjs +24 -0
- package/dist/stylelint/stylelint-config/stylelint-config.d.ts +9 -0
- package/dist/util/index.cjs +20 -0
- package/dist/util/index.d.ts +17 -0
- package/dist/util/watcher/watcher.cjs +99 -0
- package/dist/util/watcher/watcher.d.ts +48 -0
- package/dist/vite/index.cjs +45 -0
- package/dist/vite/index.d.ts +4 -0
- package/dist/vite/vite-config/vite-base-config.cjs +47 -0
- package/dist/vite/vite-config/vite-base-config.d.ts +9 -0
- package/dist/vite/vite-config/vite-config.cjs +40 -0
- package/dist/vite/vite-config/vite-config.d.ts +9 -0
- package/dist/vite/vite-config/vite-dev-config.cjs +23 -0
- package/dist/vite/vite-config/vite-dev-config.d.ts +9 -0
- package/dist/vite/vite-config/vite-plugin-config.cjs +97 -0
- package/dist/vite/vite-config/vite-plugin-config.d.ts +25 -0
- package/es/commitlint/commitlint-config/commitlint-config.d.ts +9 -0
- package/es/commitlint/commitlint-config/commitlint-config.mjs +28 -0
- package/es/commitlint/index.d.ts +1 -0
- package/es/commitlint/index.mjs +1 -0
- package/es/constants/index.d.ts +12 -0
- package/es/constants/index.mjs +24 -0
- package/es/eslint/eslint-config/eslint-config.d.ts +9 -0
- package/es/eslint/eslint-config/eslint-config.mjs +109 -0
- package/es/eslint/index.d.ts +1 -0
- package/es/eslint/index.mjs +1 -0
- package/es/index.d.ts +7 -0
- package/es/index.mjs +7 -0
- package/es/prettier/index.d.ts +1 -0
- package/es/prettier/index.mjs +1 -0
- package/es/prettier/prettier-config/prettier-config.d.ts +22 -0
- package/es/prettier/prettier-config/prettier-config.mjs +26 -0
- package/es/rollup/index.d.ts +2 -0
- package/es/rollup/index.mjs +2 -0
- package/es/rollup/rollup-config/dev-config.d.ts +9 -0
- package/es/rollup/rollup-config/dev-config.mjs +101 -0
- package/es/rollup/rollup-plugins/copy-file.d.ts +37 -0
- package/es/rollup/rollup-plugins/copy-file.mjs +18 -0
- package/es/rollup/rollup-plugins/ignore-compiler-file.d.ts +8 -0
- package/es/rollup/rollup-plugins/ignore-compiler-file.mjs +17 -0
- package/es/rollup/rollup-plugins/index.d.ts +2 -0
- package/es/rollup/rollup-plugins/index.mjs +2 -0
- package/es/stylelint/index.d.ts +1 -0
- package/es/stylelint/index.mjs +1 -0
- package/es/stylelint/stylelint-config/stylelint-config.d.ts +9 -0
- package/es/stylelint/stylelint-config/stylelint-config.mjs +21 -0
- package/es/util/index.d.ts +17 -0
- package/es/util/index.mjs +7 -0
- package/es/util/watcher/watcher.d.ts +48 -0
- package/es/util/watcher/watcher.mjs +95 -0
- package/es/vite/index.d.ts +4 -0
- package/es/vite/index.mjs +8 -0
- package/es/vite/vite-config/vite-base-config.d.ts +9 -0
- package/es/vite/vite-config/vite-base-config.mjs +53 -0
- package/es/vite/vite-config/vite-config.d.ts +9 -0
- package/es/vite/vite-config/vite-config.mjs +36 -0
- package/es/vite/vite-config/vite-dev-config.d.ts +9 -0
- package/es/vite/vite-config/vite-dev-config.mjs +19 -0
- package/es/vite/vite-config/vite-plugin-config.d.ts +25 -0
- package/es/vite/vite-config/vite-plugin-config.mjs +97 -0
- package/package.json +100 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import tsEslint from "typescript-eslint";
|
|
3
|
+
import eslintPluginVue from "eslint-plugin-vue";
|
|
4
|
+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
|
+
import unusedImports from "eslint-plugin-unused-imports";
|
|
6
|
+
import eslintPluginImport from "eslint-plugin-import";
|
|
7
|
+
import globals from "globals";
|
|
8
|
+
export function defineEslintConfig(...configs) {
|
|
9
|
+
return tsEslint.config(
|
|
10
|
+
/** js推荐配置 */
|
|
11
|
+
eslint.configs.recommended,
|
|
12
|
+
/** ts推荐配置 */
|
|
13
|
+
tsEslint.configs.strict,
|
|
14
|
+
tsEslint.configs.stylistic,
|
|
15
|
+
/** vue推荐配置 */
|
|
16
|
+
eslintPluginVue.configs["flat/recommended"],
|
|
17
|
+
eslintPluginPrettierRecommended,
|
|
18
|
+
eslintPluginImport.flatConfigs.recommended,
|
|
19
|
+
eslintPluginImport.flatConfigs.warnings,
|
|
20
|
+
eslintPluginImport.flatConfigs.errors,
|
|
21
|
+
eslintPluginImport.flatConfigs.typescript,
|
|
22
|
+
{
|
|
23
|
+
ignores: [
|
|
24
|
+
"**/node_modules",
|
|
25
|
+
"lerna.json",
|
|
26
|
+
"package.json",
|
|
27
|
+
"tsconfig.json",
|
|
28
|
+
"pnpm-lock.yaml",
|
|
29
|
+
"pnpm-workspace.yaml",
|
|
30
|
+
"eslint.config.mjs",
|
|
31
|
+
"**/dist",
|
|
32
|
+
"**/out",
|
|
33
|
+
"**/es",
|
|
34
|
+
"**/lib"
|
|
35
|
+
],
|
|
36
|
+
files: ["**/*.ts", "**.*.tsx", "**/*.vue"],
|
|
37
|
+
plugins: {
|
|
38
|
+
"unused-imports": unusedImports
|
|
39
|
+
},
|
|
40
|
+
languageOptions: {
|
|
41
|
+
globals: {
|
|
42
|
+
...globals.browser
|
|
43
|
+
},
|
|
44
|
+
parserOptions: {
|
|
45
|
+
ecmaFeatures: {
|
|
46
|
+
// 全局严格模式
|
|
47
|
+
impliedStrict: true,
|
|
48
|
+
// 启用 jsx
|
|
49
|
+
jsx: true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
rules: {
|
|
54
|
+
// 基础配置覆盖
|
|
55
|
+
"no-console": "off",
|
|
56
|
+
"no-debugger": "off",
|
|
57
|
+
"no-undef": "off",
|
|
58
|
+
"no-plusplus": [
|
|
59
|
+
"error",
|
|
60
|
+
{
|
|
61
|
+
allowForLoopAfterthoughts: true
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"no-underscore-dangle": "off",
|
|
65
|
+
"no-restricted-syntax": "off",
|
|
66
|
+
"no-continue": "off",
|
|
67
|
+
"no-unused-vars": "off",
|
|
68
|
+
"no-extraneous-class": "off",
|
|
69
|
+
"no-param-reassign": "off",
|
|
70
|
+
"no-useless-constructor": "off",
|
|
71
|
+
"no-empty-function": "off",
|
|
72
|
+
// unused-imports 配置覆盖
|
|
73
|
+
"unused-imports/no-unused-imports": "error",
|
|
74
|
+
"consistent-return": "off",
|
|
75
|
+
"func-names": "off",
|
|
76
|
+
// import 配置覆盖
|
|
77
|
+
"import/no-unresolved": "off",
|
|
78
|
+
"import/extensions": "off",
|
|
79
|
+
"import/prefer-default-export": "off",
|
|
80
|
+
// vue 配置覆盖
|
|
81
|
+
"vue/no-setup-props-destructure": "off",
|
|
82
|
+
"vue/require-default-prop": "off",
|
|
83
|
+
// typescript 配置覆盖
|
|
84
|
+
"@typescript-eslint/no-unused-vars": [
|
|
85
|
+
"error",
|
|
86
|
+
{
|
|
87
|
+
argsIgnorePattern: "^_"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
91
|
+
"@typescript-eslint/no-explicit-any": ["error"],
|
|
92
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
93
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
94
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
95
|
+
// 其他配置覆盖
|
|
96
|
+
"class-methods-use-this": "off",
|
|
97
|
+
"prefer-destructuring": "off"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "ts-vue-override",
|
|
102
|
+
files: ["**/*.vue"],
|
|
103
|
+
rules: {
|
|
104
|
+
"@typescript-eslint/no-unused-vars": "off"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
...configs
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineEslintConfig } from './eslint-config/eslint-config';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineEslintConfig } from "./eslint-config/eslint-config.mjs";
|
package/es/index.d.ts
ADDED
package/es/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./commitlint/index.mjs";
|
|
2
|
+
export * from "./eslint/index.mjs";
|
|
3
|
+
export * from "./prettier/index.mjs";
|
|
4
|
+
export * from "./rollup/index.mjs";
|
|
5
|
+
export * from "./stylelint/index.mjs";
|
|
6
|
+
export * from "./util/index.mjs";
|
|
7
|
+
export * from "./vite/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePrettierConfig } from './prettier-config/prettier-config';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePrettierConfig } from "./prettier-config/prettier-config.mjs";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Options } from 'prettier';
|
|
2
|
+
/**
|
|
3
|
+
* 基于基础配置,定义 prettier 配置
|
|
4
|
+
*
|
|
5
|
+
* @description 提交信息规范,提交格式: type: description
|
|
6
|
+
* feat: 新功能(feature)
|
|
7
|
+
* fix: 修补bug
|
|
8
|
+
* docs: 文档(documentation)
|
|
9
|
+
* style: 格式(不影响代码运行的变动)
|
|
10
|
+
* refactor: 重构(即不是新增功能,也不是修改bug的代码变动)
|
|
11
|
+
* test: 增加测试,或测试变更
|
|
12
|
+
* perf : 性能优化
|
|
13
|
+
* revert: 撤销上一次的提交
|
|
14
|
+
* build: 构建工具或构建过程等的变动,如:关联包升级等
|
|
15
|
+
* chore: 其他修改(不在上述类型中的修改)
|
|
16
|
+
* release: 发布新版本
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
* @param {Options} config
|
|
20
|
+
* @returns {*} {Options}
|
|
21
|
+
*/
|
|
22
|
+
export declare function definePrettierConfig(config?: Options): Options;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { merge } from "lodash-es";
|
|
2
|
+
export function definePrettierConfig(config = {}) {
|
|
3
|
+
return merge(
|
|
4
|
+
{
|
|
5
|
+
// 起始格式化间隔
|
|
6
|
+
tabWidth: 2,
|
|
7
|
+
// 使用单引号
|
|
8
|
+
singleQuote: true,
|
|
9
|
+
// jsx 中使用单引号
|
|
10
|
+
jsxSingleQuote: true,
|
|
11
|
+
// 对象中的 key 是否需要引号。as-needed: 只有在必须时才要
|
|
12
|
+
quoteProps: "as-needed",
|
|
13
|
+
// 每行结尾是否需要分号
|
|
14
|
+
trailingComma: "all",
|
|
15
|
+
// 括号中参数前后补充空格
|
|
16
|
+
bracketSpacing: true,
|
|
17
|
+
// 箭头函数,参数是否添加括号
|
|
18
|
+
arrowParens: "avoid",
|
|
19
|
+
// jsx 元素最后末尾的 > ,换行放置
|
|
20
|
+
bracketSameLine: false,
|
|
21
|
+
// 设置换行符
|
|
22
|
+
endOfLine: "lf"
|
|
23
|
+
},
|
|
24
|
+
config
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { defineConfig } from "rollup";
|
|
2
|
+
import { merge } from "lodash-es";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import glob from "fast-glob";
|
|
5
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
6
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
7
|
+
import json from "@rollup/plugin-json";
|
|
8
|
+
import esbuild from "rollup-plugin-esbuild";
|
|
9
|
+
import dts from "vite-plugin-dts";
|
|
10
|
+
import vue from "@vitejs/plugin-vue";
|
|
11
|
+
import vueJsx from "@vitejs/plugin-vue-jsx";
|
|
12
|
+
import * as rf from "rimraf";
|
|
13
|
+
import cpy from "cpy";
|
|
14
|
+
import fs from "fs-extra";
|
|
15
|
+
import { copyFile, ignoreCompilerFile } from "../rollup-plugins/index.mjs";
|
|
16
|
+
import { DEFAULT_EXTERNAL, PROD_MODE } from "../../constants/index.mjs";
|
|
17
|
+
export function defineRollupConfig(opts = {}) {
|
|
18
|
+
process.on("SIGINT", () => {
|
|
19
|
+
process.exit();
|
|
20
|
+
});
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const isProd = process.env.NODE_ENV === PROD_MODE;
|
|
23
|
+
const rootDir = path.resolve(cwd, "src");
|
|
24
|
+
const outDir = path.resolve(cwd, "es");
|
|
25
|
+
const assetsDir = path.resolve(cwd, "public");
|
|
26
|
+
const externalCompileFileReg = /\.(vue|scss|css|less|d\.ts)+$/;
|
|
27
|
+
rf.sync(outDir);
|
|
28
|
+
const input = glob.sync("src/**/*.{ts,tsx}", {
|
|
29
|
+
cwd,
|
|
30
|
+
absolute: true,
|
|
31
|
+
onlyFiles: true,
|
|
32
|
+
ignore: ["**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
|
|
33
|
+
});
|
|
34
|
+
if (isProd) {
|
|
35
|
+
if (fs.pathExistsSync(assetsDir)) {
|
|
36
|
+
cpy(assetsDir, outDir);
|
|
37
|
+
}
|
|
38
|
+
cpy(path.resolve(cwd, "src/**/*.{vue,scss,css,less,d.ts}"), outDir);
|
|
39
|
+
} else {
|
|
40
|
+
copyFile([
|
|
41
|
+
{
|
|
42
|
+
from: assetsDir,
|
|
43
|
+
to: outDir
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
from: rootDir,
|
|
47
|
+
to: outDir,
|
|
48
|
+
opts: {
|
|
49
|
+
ignored: (file, stats) => {
|
|
50
|
+
if (stats && stats.isFile()) {
|
|
51
|
+
return !externalCompileFileReg.test(file);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
const output = [
|
|
60
|
+
{
|
|
61
|
+
dir: outDir,
|
|
62
|
+
format: "es",
|
|
63
|
+
sourcemap: false,
|
|
64
|
+
preserveModules: true,
|
|
65
|
+
preserveModulesRoot: rootDir,
|
|
66
|
+
entryFileNames: "[name].mjs"
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
return merge(
|
|
70
|
+
defineConfig({
|
|
71
|
+
input,
|
|
72
|
+
treeshake: false,
|
|
73
|
+
external: DEFAULT_EXTERNAL,
|
|
74
|
+
output,
|
|
75
|
+
plugins: [
|
|
76
|
+
ignoreCompilerFile(externalCompileFileReg),
|
|
77
|
+
json(),
|
|
78
|
+
vue({
|
|
79
|
+
isProduction: false
|
|
80
|
+
}),
|
|
81
|
+
vueJsx({}),
|
|
82
|
+
nodeResolve({
|
|
83
|
+
extensions: [".cjs", ".mjs", ".js", ".ts"]
|
|
84
|
+
}),
|
|
85
|
+
commonjs(),
|
|
86
|
+
esbuild({
|
|
87
|
+
logLevel: "verbose",
|
|
88
|
+
sourceMap: false,
|
|
89
|
+
target: ["esnext"],
|
|
90
|
+
loaders: {
|
|
91
|
+
".vue": "ts"
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
dts({
|
|
95
|
+
outDir: [outDir]
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
}),
|
|
99
|
+
opts
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as chokidar from 'chokidar';
|
|
2
|
+
/**
|
|
3
|
+
* 文件拷贝插件配置参数
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @interface CopyFilePluginOptions
|
|
7
|
+
*/
|
|
8
|
+
export interface CopyFilePluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* 源文件
|
|
11
|
+
*
|
|
12
|
+
* @type {string}
|
|
13
|
+
* @memberof CopyFilePluginOptions
|
|
14
|
+
*/
|
|
15
|
+
from: string;
|
|
16
|
+
/**
|
|
17
|
+
* 目标文件
|
|
18
|
+
*
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @memberof CopyFilePluginOptions
|
|
21
|
+
*/
|
|
22
|
+
to: string;
|
|
23
|
+
/**
|
|
24
|
+
* chokidar watch 配置
|
|
25
|
+
*
|
|
26
|
+
* @type {chokidar.ChokidarOptions}
|
|
27
|
+
*/
|
|
28
|
+
opts?: chokidar.ChokidarOptions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 文件拷贝插件,在开发模式下会监控文件变更,并自动拷贝文件
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
* @param {CopyFilePluginOptions[]} opts
|
|
35
|
+
* @return {*} {Plugin}
|
|
36
|
+
*/
|
|
37
|
+
export declare function copyFile(opts: CopyFilePluginOptions[]): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CopyWatch } from "../../util/index.mjs";
|
|
2
|
+
export function copyFile(opts) {
|
|
3
|
+
if (opts.length === 0) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const arr = [];
|
|
7
|
+
opts.forEach((opt) => {
|
|
8
|
+
arr.push(new CopyWatch(opt.from, opt.to, opt.opts));
|
|
9
|
+
});
|
|
10
|
+
process.on("exit", () => {
|
|
11
|
+
if (!opts.length) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
arr.forEach((item) => {
|
|
15
|
+
item.unwatch();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function ignoreCompilerFile(extReg) {
|
|
2
|
+
return {
|
|
3
|
+
name: "gct:ignore-compiler-file",
|
|
4
|
+
resolveId(source) {
|
|
5
|
+
if (extReg.test(source)) {
|
|
6
|
+
return {
|
|
7
|
+
id: source,
|
|
8
|
+
external: true
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
},
|
|
13
|
+
load() {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineStylelintConfig } from './stylelint-config/stylelint-config';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineStylelintConfig } from "./stylelint-config/stylelint-config.mjs";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { merge } from "lodash-es";
|
|
2
|
+
export function defineStylelintConfig(config = {}) {
|
|
3
|
+
return merge(
|
|
4
|
+
{
|
|
5
|
+
extends: ["stylelint-config-standard", "stylelint-config-standard-scss"],
|
|
6
|
+
rules: {
|
|
7
|
+
"annotation-no-unknown": null,
|
|
8
|
+
"color-no-invalid-hex": true,
|
|
9
|
+
"function-name-case": null,
|
|
10
|
+
// 强制样式方法名称小写或大写
|
|
11
|
+
"no-duplicate-selectors": null,
|
|
12
|
+
"selector-class-pattern": null,
|
|
13
|
+
"scss/dollar-variable-pattern": null,
|
|
14
|
+
"scss/at-function-pattern": null,
|
|
15
|
+
"scss/dollar-variable-empty-line-before": null
|
|
16
|
+
// 变量声明之间不可以有空白行
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
config
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { CopyWatch } from './watcher/watcher';
|
|
2
|
+
/**
|
|
3
|
+
* win 路径 \\ 转 linux 路径 /
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @param {string} pathStr
|
|
7
|
+
* @return {*} {string}
|
|
8
|
+
*/
|
|
9
|
+
export declare function winToUnixPath(pathStr: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* linux 路径 / 转 win 路径 \\
|
|
12
|
+
*
|
|
13
|
+
* @export
|
|
14
|
+
* @param {string} pathStr
|
|
15
|
+
* @return {*} {string}
|
|
16
|
+
*/
|
|
17
|
+
export declare function unixToWinPath(pathStr: string): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as chokidar from 'chokidar';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { EventName } from 'chokidar/handler';
|
|
4
|
+
/**
|
|
5
|
+
* 文件监控类
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @class CopyWatch
|
|
9
|
+
*/
|
|
10
|
+
export declare class CopyWatch {
|
|
11
|
+
dir: string;
|
|
12
|
+
copyDir: string;
|
|
13
|
+
protected w: chokidar.FSWatcher;
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of CopyWatch.
|
|
16
|
+
*
|
|
17
|
+
* @param {string[]} dir 需要监控的目录
|
|
18
|
+
* @param {string} copyDir 需要拷贝到的目录
|
|
19
|
+
*/
|
|
20
|
+
constructor(dir: string, copyDir: string, opts?: chokidar.ChokidarOptions);
|
|
21
|
+
/**
|
|
22
|
+
* 初始化
|
|
23
|
+
*
|
|
24
|
+
* @protected
|
|
25
|
+
*/
|
|
26
|
+
protected init(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 文件监控变更
|
|
29
|
+
*
|
|
30
|
+
* @protected
|
|
31
|
+
* @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
|
|
32
|
+
* @param {string} pathStr
|
|
33
|
+
* @param {(fs.Stats)} [stats]
|
|
34
|
+
*/
|
|
35
|
+
protected watchAll(eventName: EventName, pathStr: string, stats?: fs.Stats): void;
|
|
36
|
+
/**
|
|
37
|
+
* 文件监控异常
|
|
38
|
+
*
|
|
39
|
+
* @protected
|
|
40
|
+
* @param {string} path
|
|
41
|
+
* @param {(fs.Stats | undefined)} [stats]
|
|
42
|
+
*/
|
|
43
|
+
protected watchErr(err: unknown): void;
|
|
44
|
+
/**
|
|
45
|
+
* 停止监控
|
|
46
|
+
*/
|
|
47
|
+
unwatch(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as chokidar from "chokidar";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import * as rimraf from "rimraf";
|
|
4
|
+
import { copyFileSync } from "copy-file";
|
|
5
|
+
import log from "consola";
|
|
6
|
+
import colors from "picocolors";
|
|
7
|
+
import { merge } from "lodash-es";
|
|
8
|
+
export class CopyWatch {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of CopyWatch.
|
|
11
|
+
*
|
|
12
|
+
* @param {string[]} dir 需要监控的目录
|
|
13
|
+
* @param {string} copyDir 需要拷贝到的目录
|
|
14
|
+
*/
|
|
15
|
+
constructor(dir, copyDir, opts = {}) {
|
|
16
|
+
this.dir = dir;
|
|
17
|
+
this.copyDir = copyDir;
|
|
18
|
+
this.w = chokidar.watch(
|
|
19
|
+
this.dir,
|
|
20
|
+
merge(
|
|
21
|
+
{
|
|
22
|
+
awaitWriteFinish: {
|
|
23
|
+
stabilityThreshold: 300
|
|
24
|
+
// 等待0.3秒防抖
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
opts
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
log.debug(`\u62F7\u8D1D\u76D1\u63A7\u6587\u4EF6\u5939: ${this.dir}`);
|
|
31
|
+
this.init();
|
|
32
|
+
}
|
|
33
|
+
w;
|
|
34
|
+
/**
|
|
35
|
+
* 初始化
|
|
36
|
+
*
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
39
|
+
init() {
|
|
40
|
+
this.watchAll = this.watchAll.bind(this);
|
|
41
|
+
this.watchErr = this.watchErr.bind(this);
|
|
42
|
+
this.w.on("all", this.watchAll);
|
|
43
|
+
this.w.on("error", this.watchErr);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 文件监控变更
|
|
47
|
+
*
|
|
48
|
+
* @protected
|
|
49
|
+
* @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
|
|
50
|
+
* @param {string} pathStr
|
|
51
|
+
* @param {(fs.Stats)} [stats]
|
|
52
|
+
*/
|
|
53
|
+
watchAll(eventName, pathStr, stats) {
|
|
54
|
+
if (stats && stats.size <= 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const cwd = process.cwd();
|
|
58
|
+
const source = path.resolve(cwd, pathStr);
|
|
59
|
+
const target = path.resolve(this.copyDir, path.relative(this.dir, pathStr));
|
|
60
|
+
switch (eventName) {
|
|
61
|
+
case "add":
|
|
62
|
+
case "change":
|
|
63
|
+
log.info(`\u62F7\u8D1D\u6587\u4EF6: ${colors.cyan(source)} => ${colors.cyan(target)}`);
|
|
64
|
+
copyFileSync(source, target);
|
|
65
|
+
break;
|
|
66
|
+
case "addDir":
|
|
67
|
+
break;
|
|
68
|
+
case "unlink":
|
|
69
|
+
case "unlinkDir":
|
|
70
|
+
log.info(`\u5220\u9664\u6587\u4EF6\u6216\u76EE\u5F55: ${target}`);
|
|
71
|
+
rimraf.sync(target);
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 文件监控异常
|
|
78
|
+
*
|
|
79
|
+
* @protected
|
|
80
|
+
* @param {string} path
|
|
81
|
+
* @param {(fs.Stats | undefined)} [stats]
|
|
82
|
+
*/
|
|
83
|
+
watchErr(err) {
|
|
84
|
+
log.error(`\u76D1\u63A7\u6587\u4EF6\u53D1\u751F\u9519\u8BEF: ${err}`);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 停止监控
|
|
88
|
+
*/
|
|
89
|
+
unwatch() {
|
|
90
|
+
this.w.off("all", this.watchAll);
|
|
91
|
+
this.w.off("error", this.watchErr);
|
|
92
|
+
this.w.unwatch(this.dir);
|
|
93
|
+
this.w.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { defineViteBaseConfig } from './vite-config/vite-base-config';
|
|
2
|
+
export { defineViteConfig } from './vite-config/vite-config';
|
|
3
|
+
export { defineDevViteConfig } from './vite-config/vite-dev-config';
|
|
4
|
+
export { defineDesignPluginViteConfig, defineMobilePluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { defineViteBaseConfig } from "./vite-config/vite-base-config.mjs";
|
|
2
|
+
export { defineViteConfig } from "./vite-config/vite-config.mjs";
|
|
3
|
+
export { defineDevViteConfig } from "./vite-config/vite-dev-config.mjs";
|
|
4
|
+
export {
|
|
5
|
+
defineDesignPluginViteConfig,
|
|
6
|
+
defineMobilePluginViteConfig,
|
|
7
|
+
defineWebPluginViteConfig
|
|
8
|
+
} from "./vite-config/vite-plugin-config.mjs";
|