rexma-design 2.0.2 → 2.0.3

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/gulpfile.js ADDED
@@ -0,0 +1,135 @@
1
+ const gulp = require('gulp');
2
+ const ts = require('gulp-typescript');
3
+ const cleanCSS = require('gulp-clean-css');
4
+ const uglify = require('gulp-uglify');
5
+ const rename = require('gulp-rename');
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ // 创建两个独立的 TypeScript 项目实例
10
+ const tsProjectJS = ts.createProject('tsconfig.lib.json', {
11
+ declaration: false,
12
+ emitDeclarationOnly: false
13
+ });
14
+
15
+ const tsProjectDTS = ts.createProject('tsconfig.lib.json', {
16
+ declaration: true,
17
+ emitDeclarationOnly: true
18
+ });
19
+
20
+ // 清理 lib 目录
21
+ function clean(cb) {
22
+ const libPath = path.join(__dirname, 'lib');
23
+ if (fs.existsSync(libPath)) {
24
+ fs.rmSync(libPath, { recursive: true, force: true });
25
+ }
26
+ cb();
27
+ }
28
+
29
+ // 只编译 TypeScript 文件(排除原始 index.ts)
30
+ function compileTS() {
31
+ return gulp.src(['src/packages/**/*.ts', '!src/packages/index.ts'])
32
+ .pipe(tsProjectJS())
33
+ .js.pipe(gulp.dest('lib'));
34
+ }
35
+
36
+ // 生成类型声明文件
37
+ function generateDTS() {
38
+ return gulp.src(['src/packages/**/*.ts', '!src/packages/index.ts'])
39
+ .pipe(tsProjectDTS())
40
+ .dts.pipe(gulp.dest('lib'));
41
+ }
42
+
43
+ // 复制 Vue 文件
44
+ function copyVue() {
45
+ return gulp.src('src/packages/**/*.vue')
46
+ .pipe(gulp.dest('lib'));
47
+ }
48
+
49
+ // 动态生成入口文件
50
+ function createIndex(cb) {
51
+ const packagesDir = path.join(__dirname, 'src/packages');
52
+ const items = fs.readdirSync(packagesDir, { withFileTypes: true });
53
+
54
+ let jsExports = [];
55
+ let dtsExports = [];
56
+
57
+ items.forEach(item => {
58
+ if (item.isDirectory()) {
59
+ const dirPath = path.join(packagesDir, item.name);
60
+ const indexTsPath = path.join(dirPath, 'index.ts');
61
+ const indexVuePath = path.join(dirPath, 'index.vue');
62
+
63
+ if (fs.existsSync(indexTsPath)) {
64
+ // TypeScript 模块
65
+ jsExports.push(`export { default as ${item.name} } from './${item.name}';`);
66
+ dtsExports.push(`export { default as ${item.name} } from './${item.name}';`);
67
+ } else if (fs.existsSync(indexVuePath)) {
68
+ // Vue 组件
69
+ jsExports.push(`export { default as ${item.name} } from './${item.name}/index.vue';`);
70
+ dtsExports.push(`export { default as ${item.name} } from './${item.name}/index.vue';`);
71
+ // jsExports.push(`export const ${item.name} = () => import('./${item.name}/index.vue');`);
72
+ // dtsExports.push(`export declare const ${item.name}: () => Promise<any>;`);
73
+ }
74
+ }
75
+ });
76
+
77
+ // 生成 JS 入口文件
78
+ const jsContent = jsExports.join('\n') + '\n';
79
+ fs.writeFileSync(path.join(__dirname, 'lib', 'index.js'), jsContent);
80
+
81
+ // 生成 TypeScript 声明文件
82
+ const dtsContent = dtsExports.join('\n') + '\n';
83
+ fs.writeFileSync(path.join(__dirname, 'lib', 'index.d.ts'), dtsContent);
84
+
85
+ cb();
86
+ }
87
+
88
+ // 复制其他资源文件
89
+ function copyAssets() {
90
+ return gulp.src(['src/packages/**/*.css', 'src/packages/**/*.scss', 'src/packages/**/*.less'])
91
+ .pipe(gulp.dest('lib'));
92
+ }
93
+
94
+ // 压缩 CSS 文件
95
+ function minifyCSS() {
96
+ return gulp.src('lib/**/*.css')
97
+ .pipe(cleanCSS())
98
+ .pipe(rename({ suffix: '.min' }))
99
+ .pipe(gulp.dest('lib'));
100
+ }
101
+
102
+ // 压缩 JS 文件
103
+ function minifyJS() {
104
+ return gulp.src('lib/**/*.js')
105
+ .pipe(uglify())
106
+ .pipe(rename({ suffix: '.min' }))
107
+ .pipe(gulp.dest('lib'));
108
+ }
109
+
110
+ // 监听文件变化
111
+ function watch() {
112
+ gulp.watch('src/packages/**/*.ts', gulp.series(compileTS, generateDTS, createIndex));
113
+ gulp.watch('src/packages/**/*.vue', gulp.series(copyVue, createIndex));
114
+ gulp.watch('src/packages/**/*.{css,scss,less}', gulp.series(copyAssets, minifyCSS));
115
+ }
116
+
117
+ // 构建任务
118
+ const build = gulp.series(
119
+ clean,
120
+ gulp.parallel(compileTS, generateDTS, copyVue, copyAssets),
121
+ createIndex
122
+ );
123
+
124
+ // 构建并压缩
125
+ const buildProd = gulp.series(
126
+ build,
127
+ gulp.parallel(minifyCSS, minifyJS)
128
+ );
129
+
130
+ // 导出任务
131
+ exports.clean = clean;
132
+ exports.build = build;
133
+ exports.buildProd = buildProd;
134
+ exports.watch = watch;
135
+ exports.default = build;
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { default as getValueFromUA } from './getValueFromUA';
2
1
  export { default as XinhuaClient } from './XinhuaClient';
2
+ export { default as getValueFromUA } from './getValueFromUA';
package/lib/index.js CHANGED
@@ -1,10 +1,2 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.XinhuaClient = exports.getValueFromUA = void 0;
7
- var getValueFromUA_1 = require("./getValueFromUA");
8
- Object.defineProperty(exports, "getValueFromUA", { enumerable: true, get: function () { return __importDefault(getValueFromUA_1).default; } });
9
- var XinhuaClient_1 = require("./XinhuaClient");
10
- Object.defineProperty(exports, "XinhuaClient", { enumerable: true, get: function () { return __importDefault(XinhuaClient_1).default; } });
1
+ export { default as XinhuaClient } from './XinhuaClient';
2
+ export { default as getValueFromUA } from './getValueFromUA';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "rexma-design",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "scripts": {
5
5
  "start": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
7
- "build:lib": "rm -rf lib && tsc --project tsconfig.lib.json",
7
+ "build:lib": "gulp build",
8
8
  "lint": "vue-cli-service lint",
9
9
  "prepare": "husky install"
10
10
  },
@@ -43,15 +43,16 @@
43
43
  "eslint-plugin-prettier": "^4.0.0",
44
44
  "eslint-plugin-vue": "^8.0.3",
45
45
  "eslint-webpack-plugin": "3.2.0",
46
+ "gulp": "^5.0.1",
47
+ "gulp-clean-css": "^4.3.0",
48
+ "gulp-rename": "^2.1.0",
49
+ "gulp-typescript": "^6.0.0-alpha.1",
50
+ "gulp-uglify": "^3.0.2",
46
51
  "husky": "8.0.3",
47
52
  "ky": "^1.8.1",
48
53
  "lib-flexible": "^0.3.2",
49
- "pinia": "^3.0.3",
50
- "vant": "^4.9.20",
51
- "vue": "^3.2.13",
52
- "vue-router": "^4.0.3",
53
- "xinhua-sdk": "^1.15.8",
54
54
  "lint-staged": "13.3.0",
55
+ "pinia": "^3.0.3",
55
56
  "postcss-pxtorem": "^6.1.0",
56
57
  "prettier": "^2.4.1",
57
58
  "prettier-plugin-organize-imports": "^4.1.0",
@@ -60,6 +61,10 @@
60
61
  "typescript": "~4.5.5",
61
62
  "unplugin-auto-import": "^19.3.0",
62
63
  "unplugin-vue-components": "^28.7.0",
63
- "vue-tsc": "^2.2.10"
64
+ "vant": "^4.9.20",
65
+ "vue": "^3.2.13",
66
+ "vue-router": "^4.0.3",
67
+ "vue-tsc": "^2.2.10",
68
+ "xinhua-sdk": "^1.15.8"
64
69
  }
65
70
  }