Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build zenuml/core in pnpm run build and pnpm run dev. #10

Merged
merged 1 commit into from
Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .vite/build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { build, InlineConfig, type PluginOption } from 'vite';
import { createVuePlugin as vue } from 'vite-plugin-vue2';

import { resolve } from 'path';
import { fileURLToPath } from 'url';
import jisonPlugin from './jisonPlugin.js';
import { readFileSync } from 'fs';
import { visualizer } from 'rollup-plugin-visualizer';
import type { TemplateType } from 'rollup-plugin-visualizer/dist/plugin/template-types.js';
import autoprefixer from 'autoprefixer';
import tailwindcss from 'tailwindcss';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';

const visualize = process.argv.includes('--visualize');
const watch = process.argv.includes('--watch');
Expand Down Expand Up @@ -41,6 +46,11 @@ const packageOptions = {
packageName: 'mermaid-mindmap',
file: 'detector.ts',
},
'mermaid-zenuml/zenuml/core': {
name: 'zenuml',
packageName: 'mermaid-zenuml/zenuml/core',
file: 'core.ts',
},
'mermaid-zenuml': {
name: 'mermaid-zenuml',
packageName: 'mermaid-zenuml',
Expand Down Expand Up @@ -120,6 +130,7 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
if (watch && config.build) {
config.build.watch = {
include: [
'packages/mermaid-zenuml/zenuml/core/src/**',
'packages/mermaid-zenuml/src/**',
'packages/mermaid-mindmap/src/**',
'packages/mermaid/src/**',
Expand All @@ -128,6 +139,99 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
};
}

if (entryName === 'mermaid-zenuml/zenuml/core') {
config.plugins.push(vue());
config.plugins.push(cssInjectedByJsPlugin());
config.css = {
postcss: {
plugins: [
tailwindcss({
important: '.zenuml',
content: [
'./packages/mermaid-zenuml/zenuml/core/**/*.html',
'./packages/mermaid-zenuml/zenuml/core/src/**/*.vue',
],
theme: {
extend: {
textColor: {
skin: {
title:
'var(--color-text-title, var(--color-text-message, var(--color-text-base, #000)))',
participant:
'var(--color-text-participant, var(--color-text-message, var(--color-text-base, #000)))',
message: 'var(--color-text-message, var(--color-text-base, #000))',
'message-arrow':
'var(--color-message-arrow, var(--color-border-frame, var(--color-border-base, #000)))', // message arrow head
'message-hover': 'var(--color-text-message-hover, var(--color-bg-base, #fff))',
comment:
'var(--color-text-comment, var(--color-text-secondary, var(--color-text-base, #000)))',
'fragment-header':
'var(--color-text-fragment-header, var(--color-text-message, #000))',
fragment: 'var(--color-text-fragment, var(--color-text-message, #000))',
base: 'var(--color-text-base)',
header: 'var(--color-text-header)',
secondary: 'var(--color-text-secondary)',
control:
'var(--color-text-control, var(--color-text-secondary, var(--color-text-base, #000)))',
muted: 'var(--color-text-muted)',
hover: 'var(--color-text-hover)',
link: `var(--color-text-link, var(--color-text-secondary, var(--color-text-base, #000)))`,
fill: `var(--color-text-fill)`,
},
},
backgroundColor: {
skin: {
canvas: 'var(--color-bg-canvas, var(--color-bg-base, #fff))',
frame:
'var(--color-bg-frame, var(--color-bg-canvas, var(--color-bg-base, #fff)))',
title:
'var(--color-bg-title, var(--color-bg-frame, var(--color-bg-canvas, var(--color-bg-base, #fff))))',
participant:
'var(--color-bg-participant, var(--color-bg-frame, var(--color-bg-canvas, var(--color-bg-base, #fff))))',
lifeline:
'var(--color-border-participant, var(--color-border-participant, var(--color-border-frame, var(--color-border-base, #000))))',
divider:
'var(--color-border-participant, var(--color-border-frame, var(--color-border-base, #000)))',
'message-hover': 'var(--color-bg-message-hover, var(--color-text-base, #000))',
'fragment-header': 'var(--color-bg-fragment-header, transparent)',
occurrence:
'var(--color-bg-occurrence, var(--color-bg-participant, var(--color-bg-frame, var(--color-bg-canvas, var(--color-bg-base, #fff)))))',
base: 'var(--color-bg-base)',
secondary: 'var(--color-bg-secondary)',
hover: 'var(--color-bg-hover)',
fill: 'var(--color-bg-fill)',
},
},
borderColor: {
skin: {
frame: 'var(--color-border-frame, var(--color-border-base, #000))',
participant:
'var(--color-border-participant, var(--color-border-frame, var(--color-border-base, #000)))',
'message-arrow':
'var(--color-message-arrow, var(--color-border-frame, var(--color-border-base, #000)))', // message arrow line
fragment:
'var(--color-border-fragment, var(--color-border-frame, var(--color-border-base, #000)))',
occurrence:
'var(--color-border-occurrence, var(--color-border-frame, var(--color-border-base, #000)))',
base: 'var(--color-border-base)',
secondary: 'var(--color-border-secondary)',
},
},
gradientColorStops: {
skin: {
base: 'var(--color-bg-base)',
secondary: 'var(--color-bg-secondary)',
},
},
},
},
plugins: [],
}),
autoprefixer,
],
},
};
}
return config;
};

Expand All @@ -151,6 +255,7 @@ if (watch) {
if (!mermaidOnly) {
build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-mindmap' }));
build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-zenuml' }));
build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-zenuml/zenuml/core' }));
// build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-example-diagram' }));
}
} else if (visualize) {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"git graph"
],
"scripts": {
"build:zenuml": "cd packages/mermaid-zenuml/zenuml/core && pnpm run build && cd ../../..",
"build:vite": "pnpm run build:zenuml && ts-node-esm --transpileOnly .vite/build.ts",
"build:vite": "ts-node-esm --transpileOnly .vite/build.ts",
"build:mermaid": "pnpm build:vite --mermaid",
"build:viz": "pnpm build:mermaid --visualize",
"build:types": "tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly && tsc -p ./packages/mermaid-mindmap/tsconfig.json --emitDeclarationOnly && tsc -p ./packages/mermaid-zenuml/tsconfig.json --emitDeclarationOnly",
Expand Down Expand Up @@ -73,6 +72,7 @@
"@vitejs/plugin-vue2": "^2.2.0",
"@vitest/coverage-c8": "^0.25.1",
"@vitest/ui": "^0.25.1",
"autoprefixer": "^10.4.13",
"concurrently": "^7.5.0",
"coveralls": "^3.1.1",
"cypress": "^10.11.0",
Expand Down Expand Up @@ -105,9 +105,11 @@
"rimraf": "^3.0.2",
"rollup-plugin-visualizer": "^5.8.3",
"start-server-and-test": "^1.14.0",
"tailwindcss": "^3.2.4",
"ts-node": "^10.9.1",
"typescript": "^4.8.4",
"vite": "^3.2.3",
"vite-plugin-css-injected-by-js": "^2.2.0",
"vite-plugin-vue2": "^2.0.2",
"vitest": "^0.25.3"
},
Expand Down
1 change: 0 additions & 1 deletion packages/mermaid-zenuml/src/zenumlRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { getConfig, log } from './mermaidUtils';
import ZenUml from '@zenuml/core';
import { regexp } from './detector';
import '@zenuml/core/dist/style.css';

// Create a Zen UML container outside the svg first for rendering, otherwise the Zen UML diagram cannot be rendered properly
function createTemporaryZenumlContainer(id: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid-zenuml/zenuml/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"git:forget": "git rm -r --cached . && git add . && git commit -m \"Forget all ignored files\"",
"test:specs": "echo \"Error: test:specs is not supported\""
},
"main": "./dist/zenuml-core.mjs",
"main": "./dist/zenuml.esm.mjs",
"types": "./types/index.d.ts",
"dependencies": {
"@types/assert": "^1.5.4",
Expand Down
Loading