Skip to content

Commit 64ae9e9

Browse files
committed
feat(esbuild): Add colorful output for bundle script.
1 parent 437e27b commit 64ae9e9

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

esbuild.assets.config.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import builtins from 'builtin-modules'
55
import cssModulesPlugin from "esbuild-css-modules-plugin"
66
import {sassPlugin} from 'esbuild-sass-plugin'
77
import fse from 'fs-extra';
8+
import chalk from 'chalk';
89

9-
console.log('bundling js...');
10+
console.log(chalk.blue('bundling js...'));
1011

1112
// JS assets
1213
esbuild
@@ -31,8 +32,15 @@ esbuild
3132
keepNames: true, // 保留函数和变量的原始名称
3233
globalName: 'UtilsGlobal' // 设置全局变量的名称
3334
})
35+
.then((result) => {
36+
if (result.errors?.length > 0) {
37+
console.log(chalk.red('bundle js failed: ', result.errors));
38+
} else {
39+
console.log(chalk.green('bundle js success'));
40+
}
41+
})
3442

35-
console.log('bundling styles...');
43+
console.log(chalk.blue('bundling styles...'));
3644
// Style assets
3745
esbuild
3846
.build({
@@ -59,4 +67,9 @@ esbuild
5967
.then(result => {
6068
fse.rmSync('./assets/obsidian-styles.txt.js')
6169
fse.rmSync('./assets/plugin-styles.txt.js')
70+
if (result.errors?.length > 0) {
71+
console.log(chalk.red('bundle style failed: ', result.errors));
72+
} else {
73+
console.log(chalk.green('bundle style success'));
74+
}
6275
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"builtin-modules": "^3.2.0",
4343
"chai": "^4.3.6",
4444
"chai-as-promised": "^7.1.1",
45+
"chalk": "^5.3.0",
4546
"cross-env": "^7.0.3",
4647
"dotenv": "^16.0.0",
4748
"downloadjs": "^1.4.7",

pnpm-lock.yaml

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)