create-bc-app 1.1.9 → 1.2.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.
- package/dist/index.mjs +1 -1
- package/package.json +3 -2
- package/template-monorepo/.gitlab-ci.yml +41 -0
- package/template-monorepo/README.md +8 -3
- package/template-monorepo/apps/App-A/vite.config.ts +7 -4
- package/template-monorepo/config/fileWatcher.plugin.ts +29 -0
- package/template-webcad/README.md +102 -0
- package/template-webcad/eslint.config.js +109 -0
- package/template-webcad/index.html +14 -0
- package/template-webcad/package.json +32 -0
- package/template-webcad/public/gpu-browser.js +19520 -0
- package/template-webcad/public/vite.svg +1 -0
- package/template-webcad/src/App.vue +26 -0
- package/template-webcad/src/assets/vue.svg +1 -0
- package/template-webcad/src/main.ts +5 -0
- package/template-webcad/src/sdk/apis/api.ts +111 -0
- package/template-webcad/src/sdk/cmd/cmd_types.ts +7 -0
- package/template-webcad/src/sdk/cmd/index.ts +1 -0
- package/template-webcad/src/sdk/index.ts +5 -0
- package/template-webcad/src/sdk/template_app.ts +53 -0
- package/template-webcad/src/sdk/view/scene/template_scene_creator.ts +9 -0
- package/template-webcad/src/sdk/view/template_canvas.ts +43 -0
- package/template-webcad/src/sdk/view/template_canvas_observer.ts +5 -0
- package/template-webcad/src/style.css +77 -0
- package/template-webcad/src/vite-env.d.ts +1 -0
- package/template-webcad/tsconfig.app.json +14 -0
- package/template-webcad/tsconfig.json +46 -0
- package/template-webcad/tsconfig.node.json +24 -0
- package/template-webcad/vite.config.ts +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="container"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { onMounted, ref } from "vue";
|
|
7
|
+
import { TemplateApp } from "./sdk";
|
|
8
|
+
import { TemplateCanvas } from "./sdk/view/template_canvas";
|
|
9
|
+
|
|
10
|
+
let app: TemplateApp;
|
|
11
|
+
let view: TemplateCanvas;
|
|
12
|
+
onMounted( async () => {
|
|
13
|
+
app = TemplateApp.getInstance();
|
|
14
|
+
( window as any ).app = app;
|
|
15
|
+
let container = document.getElementById( 'container' );
|
|
16
|
+
view = await app.addTemplateView( container );
|
|
17
|
+
|
|
18
|
+
} );
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<style scoped>
|
|
22
|
+
#container {
|
|
23
|
+
width: 100vw;
|
|
24
|
+
height: 100vh;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import axios, { AxiosRequestConfig } from 'axios';
|
|
2
|
+
|
|
3
|
+
/** API映射表 */
|
|
4
|
+
export const apiMap = new Map();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 注册API命令的装饰器
|
|
8
|
+
* @param cmdName - 命令名称
|
|
9
|
+
*/
|
|
10
|
+
export const registerApi = (cmdName: string) => {
|
|
11
|
+
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
|
|
12
|
+
apiMap.set(cmdName, descriptor.value);
|
|
13
|
+
|
|
14
|
+
return descriptor;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class CADApi {
|
|
19
|
+
// axios请求实例
|
|
20
|
+
protected request = axios.create();
|
|
21
|
+
// 文档ID
|
|
22
|
+
protected _docId: number;
|
|
23
|
+
public baseUrl: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 构造函数
|
|
27
|
+
* @param baseUrl - 基础URL
|
|
28
|
+
*/
|
|
29
|
+
constructor(baseUrl = '/') {
|
|
30
|
+
this.request.defaults.baseURL = baseUrl;
|
|
31
|
+
this.baseUrl = baseUrl;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public get docID(): number {
|
|
35
|
+
return this._docId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 发送HTTP请求
|
|
40
|
+
* @param url - 请求URL
|
|
41
|
+
* @param param - 请求参数
|
|
42
|
+
* @param type - 请求类型(默认'post')
|
|
43
|
+
* @param needDocId - 是否需要文档ID(默认需要)
|
|
44
|
+
* @param config - 请求配置
|
|
45
|
+
* @param isParamDocId - 是否将文档ID作为参数(默认不需要)
|
|
46
|
+
* @returns 返回响应数据
|
|
47
|
+
*/
|
|
48
|
+
async httpRequest(url, param, type = 'post', needDocId = true, config = {}, isParamDocId = false) {
|
|
49
|
+
let docId = param.docId || this.docID;
|
|
50
|
+
// 如果需要文档ID且没有文档ID,创建新文档
|
|
51
|
+
if (needDocId && !docId) docId = await this.NewDocument();
|
|
52
|
+
|
|
53
|
+
if (!url.includes('docId') && needDocId) {
|
|
54
|
+
// 拼接文档ID到URL
|
|
55
|
+
if (url.includes('?')) {
|
|
56
|
+
url += `&docId=${docId}`;
|
|
57
|
+
} else {
|
|
58
|
+
url += `?docId=${docId}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 如果文档ID作为参数,添加到参数对象中
|
|
63
|
+
if (isParamDocId && needDocId) {
|
|
64
|
+
param.docId = docId;
|
|
65
|
+
}
|
|
66
|
+
// 根据请求类型发送请求
|
|
67
|
+
const res = type === 'post' ? await this.request[type](url, param, config) : await this.request[type](url, config);
|
|
68
|
+
|
|
69
|
+
return res.data;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 创建新文档的方法(未实现)
|
|
74
|
+
* @param uniqueId - 可选的唯一ID
|
|
75
|
+
*/
|
|
76
|
+
async NewDocument(uniqueId?: number) { }
|
|
77
|
+
|
|
78
|
+
async PostCADCmd<T>(cmd: any): Promise<T> { return; }
|
|
79
|
+
async GetCADShapeData(qryName: string, params: any, docId?): Promise<any> { return; }
|
|
80
|
+
|
|
81
|
+
// 预览
|
|
82
|
+
async getCmdPreview(params: any): Promise<any> { }
|
|
83
|
+
|
|
84
|
+
public getRegisterApi(apiName: string) {
|
|
85
|
+
return apiMap.get(apiName);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public async postApi(apiName, param) {
|
|
89
|
+
const api = apiMap.get(apiName);
|
|
90
|
+
|
|
91
|
+
if (!api) {
|
|
92
|
+
console.error('Api Not Found');
|
|
93
|
+
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return api.call(this, param);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 前端直接请求后台,只需要加个docId
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
requestDirectApi(config: AxiosRequestConfig, isAllResp?: boolean) {
|
|
105
|
+
const url = `doc/${config.url}`;
|
|
106
|
+
|
|
107
|
+
return this.httpRequest(config.url, config.data ?? {}, config.method ?? 'post').then((res) => {
|
|
108
|
+
return isAllResp ? res : res.data;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cmd_types';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CadApp } from '@fs/cadnginx';
|
|
2
|
+
import { TemplateCanvas } from './view/template_canvas';
|
|
3
|
+
|
|
4
|
+
export class TemplateApp extends CadApp {
|
|
5
|
+
|
|
6
|
+
protected static _instance: TemplateApp | null = null;
|
|
7
|
+
public static override getInstance() {
|
|
8
|
+
if (!this._instance) {
|
|
9
|
+
this._instance = new TemplateApp({
|
|
10
|
+
common: {
|
|
11
|
+
background_opacity: 0,
|
|
12
|
+
background_gradient: {
|
|
13
|
+
enable: true,
|
|
14
|
+
top_color: 0xD7D9E0,
|
|
15
|
+
bottom_color: 0xF7F8FA
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
CSSRender: {
|
|
19
|
+
render_css_2d: true
|
|
20
|
+
},
|
|
21
|
+
OrthogonalCamera: {
|
|
22
|
+
near: -100000,
|
|
23
|
+
far: 100000,
|
|
24
|
+
x: 1000,
|
|
25
|
+
y: -500,
|
|
26
|
+
z: 1000,
|
|
27
|
+
up: [0, 0, 1]
|
|
28
|
+
},
|
|
29
|
+
OrbitControls: {
|
|
30
|
+
autoUpdateRotateCenter: true,
|
|
31
|
+
zoomSpeed: 0.3,
|
|
32
|
+
rotateEasingTime: 200
|
|
33
|
+
},
|
|
34
|
+
ViewCube: {
|
|
35
|
+
up: [0, 0, 1],
|
|
36
|
+
dir: [1, 0, 0],
|
|
37
|
+
position: {
|
|
38
|
+
right: 100,
|
|
39
|
+
top: 100
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
(window as any).app = this._instance;
|
|
44
|
+
this;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return this._instance;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async addTemplateView(container: HTMLElement) {
|
|
51
|
+
return await this.addView<TemplateCanvas>(container, TemplateCanvas, 'template');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { View, CadApp, FSCore, FSApp, Model, Display, Command } from '@fs/cadnginx';
|
|
2
|
+
import { CMD_TYPES } from '../cmd/cmd_types';
|
|
3
|
+
import { TemplateViewObserver } from './template_canvas_observer';
|
|
4
|
+
import { TemplateSceneCreator } from './scene/template_scene_creator';
|
|
5
|
+
|
|
6
|
+
export class TemplateCanvas extends View.Cad3DCanvas {
|
|
7
|
+
|
|
8
|
+
constructor(container: HTMLElement, app: CadApp) {
|
|
9
|
+
super(container, app);
|
|
10
|
+
this._registerDisplay();
|
|
11
|
+
this.registerCommands();
|
|
12
|
+
|
|
13
|
+
this.controller.signalCameraChange.listen(() => {
|
|
14
|
+
this.displayMap.forEach(display => {
|
|
15
|
+
if (display instanceof Display.LineDisplay) {
|
|
16
|
+
display.entity.dirtyMaterial();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected getDefaultSceneCreator(...args: any[]) {
|
|
23
|
+
return new TemplateSceneCreator(...args);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected getViewObserver():any {
|
|
27
|
+
return new TemplateViewObserver(this);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected _registerDisplay() {
|
|
31
|
+
this.registerDisplayType(Model.Line, e => this.createDisplay(e, Display.LineDisplay));
|
|
32
|
+
this.registerDisplayType(Model.MeasureLine, e => this.createDisplay(e, FSApp.View.Three.Group));
|
|
33
|
+
this.registerDisplayType(FSCore.Model.DomLabel, e => this.createDisplay(e, FSApp.View.Three.DomLabel));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private registerCommands() {
|
|
37
|
+
const cmdManager = this.app.cmdManager;
|
|
38
|
+
const cmdMap = new Map<string, any>();
|
|
39
|
+
cmdMap.forEach((cmd, cmdType) => {
|
|
40
|
+
cmdManager.register(cmdType, cmd);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
a {
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #646cff;
|
|
19
|
+
text-decoration: inherit;
|
|
20
|
+
}
|
|
21
|
+
a:hover {
|
|
22
|
+
color: #535bf2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
margin: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
place-items: center;
|
|
29
|
+
min-width: 320px;
|
|
30
|
+
min-height: 100vh;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h1 {
|
|
34
|
+
font-size: 3.2em;
|
|
35
|
+
line-height: 1.1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
button {
|
|
39
|
+
border-radius: 8px;
|
|
40
|
+
border: 1px solid transparent;
|
|
41
|
+
padding: 0.6em 1.2em;
|
|
42
|
+
font-size: 1em;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
font-family: inherit;
|
|
45
|
+
background-color: #1a1a1a;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
transition: border-color 0.25s;
|
|
48
|
+
}
|
|
49
|
+
button:hover {
|
|
50
|
+
border-color: #646cff;
|
|
51
|
+
}
|
|
52
|
+
button:focus,
|
|
53
|
+
button:focus-visible {
|
|
54
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.card {
|
|
58
|
+
padding: 2em;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#app {
|
|
62
|
+
margin: 0;
|
|
63
|
+
padding: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (prefers-color-scheme: light) {
|
|
67
|
+
:root {
|
|
68
|
+
color: #213547;
|
|
69
|
+
background-color: #ffffff;
|
|
70
|
+
}
|
|
71
|
+
a:hover {
|
|
72
|
+
color: #747bff;
|
|
73
|
+
}
|
|
74
|
+
button {
|
|
75
|
+
background-color: #f9f9f9;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
5
|
+
|
|
6
|
+
/* Linting */
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noUnusedLocals": true,
|
|
9
|
+
"noUnusedParameters": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"noUncheckedSideEffectImports": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"jsx": "preserve",
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2020",
|
|
7
|
+
"dom",
|
|
8
|
+
"dom.iterable"
|
|
9
|
+
],
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"outDir": "./dist",
|
|
14
|
+
"allowSyntheticDefaultImports": true,
|
|
15
|
+
"experimentalDecorators": true,
|
|
16
|
+
"baseUrl": ".",
|
|
17
|
+
"paths": {
|
|
18
|
+
"*": [
|
|
19
|
+
"types/*"
|
|
20
|
+
],
|
|
21
|
+
"@/*":[
|
|
22
|
+
"./src/*"
|
|
23
|
+
],
|
|
24
|
+
"@fs/*":["node_modules/@fsdev/*"],
|
|
25
|
+
},
|
|
26
|
+
"resolveJsonModule": true,
|
|
27
|
+
"declaration": true,
|
|
28
|
+
"declarationDir": "./dist"
|
|
29
|
+
},
|
|
30
|
+
"include": [
|
|
31
|
+
"src/*.d.ts",
|
|
32
|
+
"src/**/*.ts",
|
|
33
|
+
"src/**/*.tsx",
|
|
34
|
+
"src/core/test/**/*.ts",
|
|
35
|
+
"src/**/*.worker.js",
|
|
36
|
+
"src/**/*.ts",
|
|
37
|
+
"src/**/**/*.vue",
|
|
38
|
+
"src/*.ts",
|
|
39
|
+
"src/**/*.ts"
|
|
40
|
+
],
|
|
41
|
+
"exclude": [
|
|
42
|
+
"node_modules",
|
|
43
|
+
"sdk"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"moduleDetection": "force",
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
|
|
16
|
+
/* Linting */
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedSideEffectImports": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["vite.config.ts"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import vue from '@vitejs/plugin-vue';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname } from 'path';
|
|
6
|
+
import dts from 'vite-plugin-dts';
|
|
7
|
+
import banner from 'vite-plugin-banner';
|
|
8
|
+
import pkg from './package.json' assert { type: 'json' };
|
|
9
|
+
|
|
10
|
+
// https://vite.dev/config/
|
|
11
|
+
export default ({ mode }) => {
|
|
12
|
+
const isDev = mode === 'development';
|
|
13
|
+
|
|
14
|
+
return defineConfig({
|
|
15
|
+
plugins: [vue(), dts({ rollupTypes: true, entryRoot: './src/sdk' }),
|
|
16
|
+
banner({
|
|
17
|
+
content: e => {
|
|
18
|
+
if(!e.endsWith('.js'))return '';
|
|
19
|
+
|
|
20
|
+
return `console.info("${pkg.name} v${pkg.version} build time: ${new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()}");`;
|
|
21
|
+
|
|
22
|
+
},
|
|
23
|
+
verify: false
|
|
24
|
+
})
|
|
25
|
+
],
|
|
26
|
+
build: {
|
|
27
|
+
lib: {
|
|
28
|
+
entry: isDev
|
|
29
|
+
? './src/main.ts' // 开发模式:带UI的入口
|
|
30
|
+
: './src/sdk/index.ts', // 生产模式:SDK入口
|
|
31
|
+
name: 'cadnginx',
|
|
32
|
+
fileName: 'index',
|
|
33
|
+
formats: ['es']
|
|
34
|
+
},
|
|
35
|
+
sourcemap: true,
|
|
36
|
+
minify: false,
|
|
37
|
+
outDir: isDev ? 'dist' : 'lib',
|
|
38
|
+
reportCompressedSize: false,
|
|
39
|
+
rollupOptions: {
|
|
40
|
+
output: {
|
|
41
|
+
sourcemapExcludeSources: false // 包含源代码在 sourcemap 中
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
resolve: {
|
|
46
|
+
alias: {
|
|
47
|
+
'@': path.resolve(dirname(fileURLToPath(import.meta.url)), 'src'),
|
|
48
|
+
'@fs/cadnginx': path.resolve(dirname(fileURLToPath(import.meta.url)), `node_modules/${mode}/cadnginx`)
|
|
49
|
+
// '@fs/cadnginx': path.resolve(dirname(fileURLToPath(import.meta.url)), '../cadnginx/src'),
|
|
50
|
+
// '@fs/fscadweb': path.resolve(dirname(fileURLToPath(import.meta.url)), '../fscadweb/src'),
|
|
51
|
+
// '@core': path.resolve(dirname(fileURLToPath(import.meta.url)), '../fscadweb/src/core'),
|
|
52
|
+
// '@app': path.resolve(dirname(fileURLToPath(import.meta.url)), '../fscadweb/src/app'),
|
|
53
|
+
// '@math': path.resolve(dirname(fileURLToPath(import.meta.url)), '../fscadweb/src/math'),
|
|
54
|
+
// 'three': path.resolve(dirname(fileURLToPath(import.meta.url)), 'node_modules/three')
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
optimizeDeps: {
|
|
58
|
+
include: ['@fs/fscadweb'] // 列出需要包含 sourcemap 的依赖
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|