Skip to content

Commit 6a10a53

Browse files
committed
Changing build environment to vite
1 parent 35423d8 commit 6a10a53

File tree

8 files changed

+56
-14
lines changed

8 files changed

+56
-14
lines changed

package.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
{
22
"name": "react-design-editor",
3-
"version": "0.0.62",
3+
"version": "0.0.69",
44
"description": "Design Editor Tools with React.js + ant.design + fabric.js",
5-
"main": "dist/react-design-editor.min.js",
6-
"typings": "lib/index.d.ts",
5+
"main": "dist/react-design-editor.cjs.js",
6+
"module": "dist/react-design-editor.es.js",
7+
"unpkg": "dist/react-design-editor.umd.js",
8+
"typings": "dist/types/index.d.ts",
79
"files": [
8-
"dist",
9-
"lib"
10+
"dist"
1011
],
1112
"scripts": {
1213
"test": "echo \"Error: no test specified\" && exit 1",
1314
"build": "npm run clean && webpack --node-env production --config webpack.prod.js && typedoc",
14-
"build:lib": "npm run tsc && webpack --node-env production --config webpack.lib.js",
15+
"build:lib": "npm run clean && vite build && tsc --project tsconfig.build.json",
16+
"build:types": "vite build && npm run build:types",
1517
"start": "npm install && npm run start:dev",
1618
"start:dev": "webpack serve --config webpack.dev.js",
1719
"serve": "http-server docs -p 4001",
1820
"ghpages": "npm run build && node scripts/ghpages",
1921
"deploy": "npm run build:lib && npm publish",
2022
"lint": "npm run tsc",
2123
"clean": "node scripts/clean",
22-
"tsc": "tsc",
24+
"tsc": "tsc --project tsconfig.build.json",
2325
"typedoc": "typedoc"
2426
},
2527
"repository": {
@@ -103,6 +105,8 @@
103105
"@types/webpack-env": "^1.16.0",
104106
"@typescript-eslint/eslint-plugin": "^8.33.0",
105107
"@typescript-eslint/parser": "^8.33.0",
108+
"@vitejs/plugin-react": "^4.5.0",
109+
"ajv": "^8.17.1",
106110
"babel-eslint": "^10.1.0",
107111
"babel-loader": "^8.1.0",
108112
"babel-plugin-dynamic-import-webpack": "^1.1.0",
@@ -133,6 +137,8 @@
133137
"typedoc": "^0.17.4",
134138
"typescript": "^4.7.4",
135139
"url-loader": "^4.1.0",
140+
"vite": "^6.3.5",
141+
"vite-plugin-dts": "^4.5.4",
136142
"webpack": "^5.99.9",
137143
"webpack-cli": "^5.1.4",
138144
"webpack-dev-server": "^5.2.1",

src/canvas/handlers/LayoutHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ export interface LayoutOptions {
1313
}
1414

1515
export default class LayoutHandler extends AbstractHandler {
16-
public runLayout(options: LayoutOptions) {
16+
public async runLayout(options: LayoutOptions) {
1717
const { type } = options;
1818
if (!type) {
1919
return;
2020
}
2121
if (type === 'dagre') {
22-
this.dagre(options);
22+
await this.dagre(options);
2323
} else if (type === 'elk') {
24-
this.elk(options);
24+
await this.elk(options);
2525
}
2626
}
2727

src/canvas/handlers/PortHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ class PortHandler {
106106
port.set({ left, top });
107107
port.setCoords();
108108
if (port.links.length) {
109-
console.log(port.links);
110109
port.links.forEach(link => {
111110
link.update({ left, top }, { left: link.toNode.toPort.left, top: link.toNode.toPort.top });
112111
});

src/canvas/handlers/TransactionHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ class TransactionHandler {
139139
*/
140140
public replay = (transaction: TransactionEvent) => {
141141
const objects = JSON.parse(transaction.json) as FabricObject[];
142-
console.log(objects);
143142
this.state = objects;
144143
this.active = true;
145144
this.handler.canvas.renderOnAddRemove = false;

src/canvas/objects/Link.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const Link = fabric.util.createClass(fabric.Group, {
3838
this.fromPort = fromPort;
3939
this.toNode = toNode;
4040
this.toPort = toPort;
41-
console.log(options);
4241
const { line, arrow } = this.draw(fromPort, toPort, options);
4342
this.line = line;
4443
this.arrow = arrow;

src/canvas/utils/ObjectUtil.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ export interface FabricEvent<T extends any = Event> extends Omit<fabric.IEvent,
405405
isClick?: boolean;
406406
pointer?: fabric.Point;
407407
absolutePointer?: fabric.Point;
408-
transform?: { corner: string; original: FabricObject; originX: string; originY: string; width: number };
409408
}
410409

411410
export type FabricObjects = {

tsconfig.build.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"declaration": true,
5+
"declarationMap": true,
6+
"emitDeclarationOnly": true,
7+
"outDir": "./dist/types",
8+
"allowJs": false
9+
},
10+
"include": ["src/canvas/index.tsx", "src/canvas/global.d.ts"],
11+
"exclude": ["node_modules", "dist"]
12+
}

vite.config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import react from '@vitejs/plugin-react';
2+
import path from 'path';
3+
import { defineConfig } from 'vite';
4+
import pkg from './package.json';
5+
6+
export default defineConfig({
7+
publicDir: false,
8+
plugins: [react()],
9+
build: {
10+
lib: {
11+
entry: path.resolve(__dirname, 'src/canvas/index.tsx'),
12+
name: pkg.name,
13+
fileName: format => `${pkg.name}.${format}.js`,
14+
formats: ['es', 'cjs', 'umd'],
15+
},
16+
rollupOptions: {
17+
external: ['react', 'react-dom'],
18+
output: {
19+
globals: {
20+
react: 'React',
21+
'react-dom': 'ReactDOM',
22+
},
23+
},
24+
},
25+
sourcemap: true,
26+
minify: 'terser', // 기본 빌드에서 압축
27+
},
28+
});

0 commit comments

Comments
 (0)