balm-core 5.2.0 → 6.0.0-alpha.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.
Files changed (299) hide show
  1. package/dist/index.cjs +2191 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +559 -0
  4. package/dist/index.d.ts +559 -0
  5. package/dist/index.js +2098 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +48 -123
  8. package/src/balm.ts +103 -0
  9. package/src/bundler/esbuild.ts +47 -0
  10. package/src/bundler/index.ts +3 -0
  11. package/src/bundler/rollup.ts +39 -0
  12. package/src/bundler/webpack.ts +82 -0
  13. package/src/config/constants.ts +12 -0
  14. package/src/config/defaults.ts +209 -0
  15. package/src/config/index.ts +112 -0
  16. package/src/hooks/index.ts +192 -0
  17. package/src/index.ts +16 -0
  18. package/src/pipeline/file.ts +69 -0
  19. package/src/pipeline/index.ts +10 -0
  20. package/src/pipeline/pipeline.ts +132 -0
  21. package/src/pipeline/transforms/cache.ts +96 -0
  22. package/src/pipeline/transforms/htmlmin.ts +18 -0
  23. package/src/pipeline/transforms/less.ts +75 -0
  24. package/src/pipeline/transforms/postcss.ts +43 -0
  25. package/src/pipeline/transforms/rename.ts +37 -0
  26. package/src/pipeline/transforms/replace.ts +30 -0
  27. package/src/pipeline/transforms/sass.ts +106 -0
  28. package/src/pipeline/transforms/terser.ts +20 -0
  29. package/src/runner/dag.ts +77 -0
  30. package/src/runner/task.ts +38 -0
  31. package/src/shims.d.ts +5 -0
  32. package/src/tasks/cache.ts +58 -0
  33. package/src/tasks/clean.ts +21 -0
  34. package/src/tasks/copy.ts +36 -0
  35. package/src/tasks/ftp.ts +90 -0
  36. package/src/tasks/html.ts +78 -0
  37. package/src/tasks/index.ts +13 -0
  38. package/src/tasks/publish.ts +71 -0
  39. package/src/tasks/pwa.ts +49 -0
  40. package/src/tasks/remove.ts +24 -0
  41. package/src/tasks/replace.ts +34 -0
  42. package/src/tasks/script.ts +28 -0
  43. package/src/tasks/server.ts +89 -0
  44. package/src/tasks/style.ts +57 -0
  45. package/src/tasks/zip.ts +65 -0
  46. package/src/types/index.ts +200 -0
  47. package/src/utilities/file.ts +120 -0
  48. package/src/utilities/logger.ts +63 -0
  49. package/src/utilities/utils.ts +46 -0
  50. package/src/utilities/workspace.ts +38 -0
  51. package/src/watcher/index.ts +100 -0
  52. package/tsconfig.json +8 -0
  53. package/tsup.config.ts +12 -0
  54. package/README.md +0 -196
  55. package/index.d.ts +0 -360
  56. package/lib/balm.js +0 -49
  57. package/lib/bootstrap/check_config.js +0 -43
  58. package/lib/bootstrap/index.js +0 -87
  59. package/lib/bundler/esbuild/build.js +0 -26
  60. package/lib/bundler/esbuild/index.js +0 -7
  61. package/lib/bundler/esbuild/options.js +0 -7
  62. package/lib/bundler/esbuild/transform.js +0 -36
  63. package/lib/bundler/rollup/build.js +0 -52
  64. package/lib/bundler/rollup/entry.js +0 -28
  65. package/lib/bundler/rollup/index.js +0 -20
  66. package/lib/bundler/rollup/output.js +0 -20
  67. package/lib/bundler/rollup/plugins.js +0 -31
  68. package/lib/bundler/webpack/config/common.js +0 -135
  69. package/lib/bundler/webpack/config/dev.js +0 -12
  70. package/lib/bundler/webpack/config/env.js +0 -67
  71. package/lib/bundler/webpack/config/index.js +0 -6
  72. package/lib/bundler/webpack/config/prod.js +0 -39
  73. package/lib/bundler/webpack/config/regex.js +0 -10
  74. package/lib/bundler/webpack/entry.js +0 -65
  75. package/lib/bundler/webpack/index.js +0 -32
  76. package/lib/bundler/webpack/loaders.js +0 -50
  77. package/lib/bundler/webpack/output.js +0 -41
  78. package/lib/bundler/webpack/rules/asset.js +0 -33
  79. package/lib/bundler/webpack/rules/babel.js +0 -19
  80. package/lib/bundler/webpack/rules/css.js +0 -109
  81. package/lib/bundler/webpack/rules/html.js +0 -15
  82. package/lib/bundler/webpack/rules/index.js +0 -10
  83. package/lib/config/assets.js +0 -30
  84. package/lib/config/constants.js +0 -14
  85. package/lib/config/env.js +0 -35
  86. package/lib/config/extras.js +0 -6
  87. package/lib/config/ftp.js +0 -6
  88. package/lib/config/globals.js +0 -43
  89. package/lib/config/html.js +0 -22
  90. package/lib/config/images.js +0 -4
  91. package/lib/config/index.js +0 -63
  92. package/lib/config/logs.js +0 -11
  93. package/lib/config/paths.js +0 -46
  94. package/lib/config/pwa.js +0 -24
  95. package/lib/config/roots.js +0 -9
  96. package/lib/config/scripts.js +0 -162
  97. package/lib/config/server.js +0 -84
  98. package/lib/config/spinner.js +0 -9
  99. package/lib/config/styles.js +0 -67
  100. package/lib/hello.js +0 -19
  101. package/lib/hooks/index.js +0 -94
  102. package/lib/hooks/maker.js +0 -59
  103. package/lib/index.js +0 -5
  104. package/lib/middlewares/history.js +0 -6
  105. package/lib/middlewares/index.js +0 -11
  106. package/lib/middlewares/proxy.js +0 -28
  107. package/lib/middlewares/webpack.js +0 -26
  108. package/lib/plugins/htmlmin.js +0 -39
  109. package/lib/plugins/imagemin.js +0 -95
  110. package/lib/plugins/index.js +0 -27
  111. package/lib/plugins/jsmin.js +0 -37
  112. package/lib/plugins/less.js +0 -97
  113. package/lib/plugins/plumber.js +0 -87
  114. package/lib/plugins/postcss-plugins.js +0 -13
  115. package/lib/plugins/postcss.js +0 -117
  116. package/lib/plugins/rename.js +0 -51
  117. package/lib/plugins/replace.js +0 -91
  118. package/lib/plugins/sass-legacy.js +0 -131
  119. package/lib/plugins/sass.js +0 -134
  120. package/lib/plugins/sftp.js +0 -288
  121. package/lib/tasks/default.js +0 -46
  122. package/lib/tasks/foundation/balm.js +0 -72
  123. package/lib/tasks/foundation/balm_style.js +0 -65
  124. package/lib/tasks/foundation/index.js +0 -10
  125. package/lib/tasks/index.js +0 -48
  126. package/lib/tasks/private/build.js +0 -18
  127. package/lib/tasks/private/cache.js +0 -31
  128. package/lib/tasks/private/clean.js +0 -69
  129. package/lib/tasks/private/end.js +0 -24
  130. package/lib/tasks/private/extra.js +0 -35
  131. package/lib/tasks/private/font.js +0 -15
  132. package/lib/tasks/private/image.js +0 -37
  133. package/lib/tasks/private/index.js +0 -34
  134. package/lib/tasks/private/lint.js +0 -20
  135. package/lib/tasks/private/media.js +0 -15
  136. package/lib/tasks/private/modernizr.js +0 -59
  137. package/lib/tasks/private/pwa-cache.js +0 -32
  138. package/lib/tasks/private/script.js +0 -9
  139. package/lib/tasks/private/sprite.js +0 -105
  140. package/lib/tasks/private/start.js +0 -16
  141. package/lib/tasks/private/style.js +0 -9
  142. package/lib/tasks/private/workbox-sw.js +0 -15
  143. package/lib/tasks/public/copy.js +0 -16
  144. package/lib/tasks/public/esbuild.js +0 -18
  145. package/lib/tasks/public/ftp.js +0 -39
  146. package/lib/tasks/public/html.js +0 -65
  147. package/lib/tasks/public/index.js +0 -38
  148. package/lib/tasks/public/jsmin.js +0 -23
  149. package/lib/tasks/public/less.js +0 -21
  150. package/lib/tasks/public/postcss.js +0 -16
  151. package/lib/tasks/public/publish.js +0 -51
  152. package/lib/tasks/public/pwa.js +0 -84
  153. package/lib/tasks/public/remove.js +0 -46
  154. package/lib/tasks/public/replace.js +0 -26
  155. package/lib/tasks/public/rollup.js +0 -17
  156. package/lib/tasks/public/sass.js +0 -27
  157. package/lib/tasks/public/server.js +0 -130
  158. package/lib/tasks/public/url.js +0 -35
  159. package/lib/tasks/public/version.js +0 -23
  160. package/lib/tasks/public/webpack.js +0 -39
  161. package/lib/tasks/public/zip.js +0 -19
  162. package/lib/utilities/address.js +0 -55
  163. package/lib/utilities/cache-core.js +0 -66
  164. package/lib/utilities/color.js +0 -27
  165. package/lib/utilities/compiling.js +0 -24
  166. package/lib/utilities/detect-port.js +0 -100
  167. package/lib/utilities/escape-string-regexp.js +0 -10
  168. package/lib/utilities/file.js +0 -70
  169. package/lib/utilities/index.js +0 -8
  170. package/lib/utilities/loading.js +0 -37
  171. package/lib/utilities/logger.js +0 -99
  172. package/lib/utilities/merge-stream.js +0 -38
  173. package/lib/utilities/namespace.js +0 -11
  174. package/lib/utilities/public-url.js +0 -37
  175. package/lib/utilities/replacestream.js +0 -106
  176. package/lib/utilities/typeof.js +0 -5
  177. package/lib/utilities/utils.js +0 -43
  178. package/tslib/balm.js +0 -44
  179. package/tslib/bootstrap/check_config.js +0 -36
  180. package/tslib/bootstrap/index.js +0 -82
  181. package/tslib/bundler/esbuild/build.js +0 -30
  182. package/tslib/bundler/esbuild/index.js +0 -11
  183. package/tslib/bundler/esbuild/options.js +0 -7
  184. package/tslib/bundler/esbuild/transform.js +0 -38
  185. package/tslib/bundler/rollup/build.js +0 -17
  186. package/tslib/bundler/rollup/entry.js +0 -24
  187. package/tslib/bundler/rollup/index.js +0 -21
  188. package/tslib/bundler/rollup/output.js +0 -23
  189. package/tslib/bundler/rollup/plugins.js +0 -27
  190. package/tslib/bundler/webpack/config/common.js +0 -130
  191. package/tslib/bundler/webpack/config/dev.js +0 -14
  192. package/tslib/bundler/webpack/config/env.js +0 -44
  193. package/tslib/bundler/webpack/config/index.js +0 -8
  194. package/tslib/bundler/webpack/config/prod.js +0 -43
  195. package/tslib/bundler/webpack/config/regex.js +0 -10
  196. package/tslib/bundler/webpack/entry.js +0 -68
  197. package/tslib/bundler/webpack/index.js +0 -30
  198. package/tslib/bundler/webpack/loaders.js +0 -51
  199. package/tslib/bundler/webpack/output.js +0 -41
  200. package/tslib/bundler/webpack/rules/asset.js +0 -33
  201. package/tslib/bundler/webpack/rules/babel.js +0 -16
  202. package/tslib/bundler/webpack/rules/css.js +0 -95
  203. package/tslib/bundler/webpack/rules/html.js +0 -15
  204. package/tslib/bundler/webpack/rules/index.js +0 -10
  205. package/tslib/config/assets.js +0 -24
  206. package/tslib/config/constants.js +0 -14
  207. package/tslib/config/env.js +0 -43
  208. package/tslib/config/extras.js +0 -6
  209. package/tslib/config/ftp.js +0 -6
  210. package/tslib/config/globals.js +0 -47
  211. package/tslib/config/html.js +0 -17
  212. package/tslib/config/images.js +0 -4
  213. package/tslib/config/index.js +0 -56
  214. package/tslib/config/logs.js +0 -6
  215. package/tslib/config/paths.js +0 -30
  216. package/tslib/config/pwa.js +0 -18
  217. package/tslib/config/roots.js +0 -8
  218. package/tslib/config/scripts.js +0 -93
  219. package/tslib/config/server.js +0 -33
  220. package/tslib/config/spinner.js +0 -10
  221. package/tslib/config/styles.js +0 -37
  222. package/tslib/hello.js +0 -19
  223. package/tslib/hooks/index.js +0 -75
  224. package/tslib/hooks/maker.js +0 -66
  225. package/tslib/index.js +0 -5
  226. package/tslib/middlewares/history.js +0 -12
  227. package/tslib/middlewares/index.js +0 -18
  228. package/tslib/middlewares/proxy.js +0 -27
  229. package/tslib/middlewares/webpack.js +0 -29
  230. package/tslib/plugins/htmlmin.js +0 -38
  231. package/tslib/plugins/imagemin.js +0 -97
  232. package/tslib/plugins/index.js +0 -27
  233. package/tslib/plugins/jsmin.js +0 -39
  234. package/tslib/plugins/less.js +0 -90
  235. package/tslib/plugins/plumber.js +0 -81
  236. package/tslib/plugins/postcss-plugins.js +0 -24
  237. package/tslib/plugins/postcss.js +0 -111
  238. package/tslib/plugins/rename.js +0 -51
  239. package/tslib/plugins/replace.js +0 -72
  240. package/tslib/plugins/sass-legacy.js +0 -95
  241. package/tslib/plugins/sass.js +0 -109
  242. package/tslib/plugins/sftp.js +0 -258
  243. package/tslib/tasks/default.js +0 -59
  244. package/tslib/tasks/foundation/balm.js +0 -75
  245. package/tslib/tasks/foundation/balm_style.js +0 -68
  246. package/tslib/tasks/foundation/index.js +0 -10
  247. package/tslib/tasks/index.js +0 -43
  248. package/tslib/tasks/private/build.js +0 -15
  249. package/tslib/tasks/private/cache.js +0 -48
  250. package/tslib/tasks/private/clean.js +0 -82
  251. package/tslib/tasks/private/end.js +0 -21
  252. package/tslib/tasks/private/extra.js +0 -34
  253. package/tslib/tasks/private/font.js +0 -12
  254. package/tslib/tasks/private/image.js +0 -42
  255. package/tslib/tasks/private/index.js +0 -34
  256. package/tslib/tasks/private/lint.js +0 -17
  257. package/tslib/tasks/private/media.js +0 -12
  258. package/tslib/tasks/private/modernizr.js +0 -54
  259. package/tslib/tasks/private/pwa-cache.js +0 -32
  260. package/tslib/tasks/private/script.js +0 -9
  261. package/tslib/tasks/private/sprite.js +0 -93
  262. package/tslib/tasks/private/start.js +0 -13
  263. package/tslib/tasks/private/style.js +0 -12
  264. package/tslib/tasks/private/workbox-sw.js +0 -15
  265. package/tslib/tasks/public/copy.js +0 -18
  266. package/tslib/tasks/public/esbuild.js +0 -18
  267. package/tslib/tasks/public/ftp.js +0 -39
  268. package/tslib/tasks/public/html.js +0 -75
  269. package/tslib/tasks/public/index.js +0 -38
  270. package/tslib/tasks/public/jsmin.js +0 -24
  271. package/tslib/tasks/public/less.js +0 -21
  272. package/tslib/tasks/public/postcss.js +0 -16
  273. package/tslib/tasks/public/publish.js +0 -50
  274. package/tslib/tasks/public/pwa.js +0 -87
  275. package/tslib/tasks/public/remove.js +0 -44
  276. package/tslib/tasks/public/replace.js +0 -27
  277. package/tslib/tasks/public/rollup.js +0 -17
  278. package/tslib/tasks/public/sass.js +0 -27
  279. package/tslib/tasks/public/server.js +0 -129
  280. package/tslib/tasks/public/url.js +0 -35
  281. package/tslib/tasks/public/version.js +0 -27
  282. package/tslib/tasks/public/webpack.js +0 -41
  283. package/tslib/tasks/public/zip.js +0 -19
  284. package/tslib/utilities/address.js +0 -48
  285. package/tslib/utilities/cache-core.js +0 -57
  286. package/tslib/utilities/color.js +0 -33
  287. package/tslib/utilities/compiling.js +0 -16
  288. package/tslib/utilities/detect-port.js +0 -91
  289. package/tslib/utilities/escape-string-regexp.js +0 -7
  290. package/tslib/utilities/file.js +0 -78
  291. package/tslib/utilities/index.js +0 -8
  292. package/tslib/utilities/loading.js +0 -25
  293. package/tslib/utilities/logger.js +0 -92
  294. package/tslib/utilities/merge-stream.js +0 -34
  295. package/tslib/utilities/namespace.js +0 -12
  296. package/tslib/utilities/public-url.js +0 -31
  297. package/tslib/utilities/replacestream.js +0 -112
  298. package/tslib/utilities/typeof.js +0 -8
  299. package/tslib/utilities/utils.js +0 -38
@@ -0,0 +1,100 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { BalmConfig } from '../types/index.js';
4
+ import { StyleTask } from '../tasks/style.js';
5
+ import { ScriptTask } from '../tasks/script.js';
6
+ import { HtmlTask } from '../tasks/html.js';
7
+ import { logger } from '../utilities/logger.js';
8
+ import pc from 'picocolors';
9
+
10
+ export interface WatcherBroadcast {
11
+ (data: { type: 'reload' | 'reload-css'; file?: string }): void;
12
+ }
13
+
14
+ export class FileWatcher {
15
+ private config: BalmConfig;
16
+ private broadcast: WatcherBroadcast;
17
+ private debounceTimer: NodeJS.Timeout | null = null;
18
+ private pendingFiles = new Set<string>();
19
+ private styleTask: StyleTask;
20
+ private scriptTask: ScriptTask;
21
+ private htmlTask: HtmlTask;
22
+ private watcher: fs.FSWatcher | null = null;
23
+
24
+ constructor(config: BalmConfig, broadcast: WatcherBroadcast) {
25
+ this.config = config;
26
+ this.broadcast = broadcast;
27
+ this.styleTask = new StyleTask();
28
+ this.scriptTask = new ScriptTask();
29
+ this.htmlTask = new HtmlTask();
30
+ }
31
+
32
+ start(): void {
33
+ const watchDir = this.config.src.base;
34
+ if (!fs.existsSync(watchDir)) return;
35
+
36
+ logger.info('watch', `Watching for file changes in ${pc.cyan(watchDir)}`);
37
+
38
+ try {
39
+ this.watcher = fs.watch(watchDir, { recursive: true }, (eventType, filename) => {
40
+ if (!filename) return;
41
+ this.pendingFiles.add(filename);
42
+
43
+ if (this.debounceTimer) clearTimeout(this.debounceTimer);
44
+ this.debounceTimer = setTimeout(() => {
45
+ this.handleChanges();
46
+ }, 50);
47
+ });
48
+ } catch (err: any) {
49
+ logger.warn('watch', `Native recursive watch failed: ${err.message}`);
50
+ }
51
+ }
52
+
53
+ private async handleChanges(): Promise<void> {
54
+ const changed = Array.from(this.pendingFiles);
55
+ this.pendingFiles.clear();
56
+
57
+ const hasStyle = changed.some((f) => /\.(scss|sass|less|css)$/i.test(f));
58
+ const hasScript = changed.some((f) => /\.(js|mjs|cjs|ts|jsx|tsx)$/i.test(f));
59
+ const hasHtml = changed.some((f) => /\.html$/i.test(f));
60
+
61
+ try {
62
+ if (hasStyle) {
63
+ const start = performance.now();
64
+ await this.styleTask.run(this.config);
65
+ const duration = (performance.now() - start).toFixed(1);
66
+ logger.info('watch', `Recompiled styles in ${pc.bold(duration + 'ms')}`);
67
+ this.broadcast({ type: 'reload-css' });
68
+ }
69
+
70
+ if (hasScript) {
71
+ const start = performance.now();
72
+ await this.scriptTask.run(this.config);
73
+ const duration = (performance.now() - start).toFixed(1);
74
+ logger.info('watch', `Rebundled scripts in ${pc.bold(duration + 'ms')}`);
75
+ this.broadcast({ type: 'reload' });
76
+ }
77
+
78
+ if (hasHtml) {
79
+ const start = performance.now();
80
+ await this.htmlTask.run(this.config);
81
+ const duration = (performance.now() - start).toFixed(1);
82
+ logger.info('watch', `Recompiled HTML in ${pc.bold(duration + 'ms')}`);
83
+ this.broadcast({ type: 'reload' });
84
+ }
85
+
86
+ if (!hasStyle && !hasScript && !hasHtml && changed.length > 0) {
87
+ this.broadcast({ type: 'reload' });
88
+ }
89
+ } catch (err: any) {
90
+ logger.error('watch', `Incremental rebuild failed: ${err?.message || err}`);
91
+ }
92
+ }
93
+
94
+ stop(): void {
95
+ if (this.watcher) {
96
+ this.watcher.close();
97
+ this.watcher = null;
98
+ }
99
+ }
100
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"]
8
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: ['src/index.ts'],
5
+ format: ['esm', 'cjs'],
6
+ dts: true,
7
+ clean: true,
8
+ sourcemap: true,
9
+ splitting: false,
10
+ shims: true,
11
+ target: 'node18'
12
+ });
package/README.md DELETED
@@ -1,196 +0,0 @@
1
- <div align="center">
2
- <a href="https://balm.js.org/">
3
- <img width="128" height="128" src="https://balm.js.org/logo.png" alt="BalmJS">
4
- </a>
5
- <br>
6
- <br>
7
-
8
- [![NPM version][balm-core-image]][balm-core-url]
9
- [![License][license-image]][license-url]
10
- [![Coverage Percentage][cover-image]][cover-url]
11
-
12
- <h1>BalmJS</h1>
13
- <p>An universal Front-End workflow for webapps</p>
14
- </div>
15
-
16
- > [`balm-core@3`](https://github.com/balmjs/balm/tree/master)(v3) supports for `node@10.13.0+`, `postcss@7`, `webpack@4`
17
-
18
- ## Introduction
19
-
20
- BalmJS prescribes best practices and tools to help you stay productive.
21
-
22
- - **Naturally**: Make web development _simple_, _natural_ and _pleasant_.
23
- - **Structure-Based**: _One configuration file_ can manage webapp projects with at least 90% use cases.
24
- - **Learn Once, Run Any Webapps**: Any front-end technology stack will be developed and built in _the same way_.
25
-
26
- ## Features
27
-
28
- - Based on **gulp + webpack** for webapp projects
29
- - Automagically compile PostCSS/Sass/Less
30
- - CSS Autoprefixing
31
- - Automagically generate CSS Image Sprites
32
- - enable ES2015+ features using Babel
33
- - Awesome images optimization
34
- - Built-in preview server with BrowserSync
35
- - Custom publish assets to remote (Front-end to Back-end) project
36
- - ZIP/FTP/PWA supported
37
- - Easily define and extend your own tasks
38
-
39
- ## Structure
40
-
41
- :rocket: We recommend using [Balm CLI](https://github.com/balmjs/balm-cli) to scaffold out a front-end web app.
42
-
43
- ```
44
- project
45
- ├── .tmp // Scaffolds out a temporary directory for development
46
- ├── dist // Scaffolds out the production build
47
- ├─┬ src // Source code in here (Create a directory in project)
48
- │ ├── fonts
49
- │ ├── images
50
- │ ├── media
51
- │ ├─┬ scripts
52
- │ │ └── index.js // Required. A entry file for JS.
53
- │ ├─┬ styles
54
- │ │ └── main.css // Required. A entry file for CSS.
55
- │ └── index.html // Required. A entry file for HTML.
56
- ├── .dotfile // (e.g. .gitignore, .browserslistrc, etc...)
57
- ├── babel.config.js
58
- ├── balm.config.js // Required. A configuration file for Balm.
59
- ├── package.json // Required.
60
- └── ...
61
- ```
62
-
63
- ## Installation
64
-
65
- ### 0. Requirements
66
-
67
- You need to set up your development environment before you can do anything.
68
-
69
- Install [Node.js® and npm](https://nodejs.org/en/download/) if they are not already on your machine.
70
-
71
- > **Verify that you are running at least node `18.12.0`** by running `node -v` in a terminal/console window. Older versions maybe produce errors, but newer versions are fine.
72
-
73
- You develop apps in the context of an [Balm workspace](https://balm.js.org/docs/guide/structure.html).
74
-
75
- To create a new workspace and initial starter app:
76
-
77
- ```sh
78
- # /path/to/YOUR_WORKSPACE
79
- mkdir -p my-project/src/{styles,scripts}
80
- echo "Hello World" > my-project/src/index.html
81
-
82
- cd my-project
83
- npm init -y
84
- ```
85
-
86
- ### 1. Installing `balm`
87
-
88
- ```sh
89
- yarn global add balm-core
90
- yarn add -D balm
91
- ```
92
-
93
- OR
94
-
95
- ```sh
96
- npm install -g balm-core
97
- npm install -D balm
98
- ```
99
-
100
- > We currently recommend using [Yarn](https://yarnpkg.com/en/docs/install) instead of npm.
101
-
102
- ### 2. Configuration
103
-
104
- In your project directory, create a file named `balm.config.js` in your project root with these contents:
105
-
106
- ```js
107
- module.exports = {
108
- // Your project config
109
- };
110
- ```
111
-
112
- :page_with_curl: Refer to [configuration docs](https://balm.js.org/docs/config/) to learn more about config **`balm`**.
113
-
114
- ### 3. Usage
115
-
116
- Edit `package.json` in your project directory:
117
-
118
- ```json
119
- {
120
- "scripts": {
121
- "dev": "balm",
122
- "prod": "balm -p"
123
- }
124
- }
125
- ```
126
-
127
- Run the command in your project directory:
128
-
129
- ```sh
130
- # For development
131
- npm run dev
132
-
133
- # For production
134
- npm run prod
135
- ```
136
-
137
- ## Demo
138
-
139
- - [x] [HTML boilerplate](https://github.com/balmjs/demo-html5-boilerplate)
140
- - [x] [Laravel](https://github.com/balmjs/demo-laravel)
141
- - [x] [TypeScript](https://github.com/balmjs/demo-ts)
142
- - [x] Yours awesome projects...
143
-
144
- ## Documentation
145
-
146
- To download [example](https://balm.js.org/balm-example.zip) and try it, visit [balm.js.org](https://balm.js.org/docs/).
147
-
148
- - [Getting Started](https://balm.js.org/docs/guide/getting-started.html)
149
- - [Configuration](https://balm.js.org/docs/config/)
150
- - [Custom Task API](https://balm.js.org/docs/api/)
151
- - [Advanced Usage](https://balm.js.org/docs/advanced/)
152
-
153
- ## Ecosystem
154
-
155
- | Project | Status | Description |
156
- | ---------------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------ |
157
- | **[balm-core](https://github.com/balmjs/balm)** | [![NPM version][balm-core-image]][balm-core-url] | :black_joker: BalmJS compiler core (required for `balm 3.0+`) |
158
- | **[balm](https://github.com/balmjs/balm)** | [![NPM version][balm-image]][balm-url] | :black_joker: BalmJS runtime core |
159
- | **[balm-cli](https://github.com/balmjs/balm-cli)** | [![NPM version][balm-cli-image]][balm-cli-url] | :spades: BalmJS scaffolding tool |
160
- | [balm-gui](https://github.com/balmjs/balm-gui) | N/A | :clubs: GUI for BalmJS |
161
- | [balm-ui-lite](https://github.com/balmjs/ui-vue-lite) | [![NPM version][balm-ui-lite-image]][balm-ui-lite-url] | :hearts: Material Design Lite + Vue |
162
- | **[balm-ui](https://github.com/balmjs/ui-vue)** | [![NPM version][balm-ui-image]][balm-ui-url] | :diamonds: Next Generation Material UI for Vue.js |
163
- | [balm-scroll](https://github.com/balmjs/balm-scroll) | [![NPM version][balm-scroll-image]][balm-scroll-url] | :scroll: Smooth scrolling for Vue.js |
164
- | **[balm-ui-pro](https://github.com/balmjs/balm-ui-pro)** | [![NPM version][balm-ui-pro-image]][balm-ui-pro-url] | More configuration definition, less code implementation for Vue.js |
165
- | **[balm-git-flow](https://github.com/balmjs/balm-ui-pro)** | [![NPM version][balm-git-flow-image]][balm-git-flow-url] | The best practices for front-end git flow |
166
-
167
- ## Contributing
168
-
169
- We'd love for you to contribute and make BalmJS even better than it is today! Please make sure to read the [Contributing Guide](https://github.com/balmjs/balm/blob/main/CONTRIBUTING.md) before making a [pull request](https://github.com/balmjs/balm/pulls). You can submit any ideas as pull requests or as [GitHub issues](https://github.com/balmjs/balm/issues).
170
-
171
- ## License
172
-
173
- [MIT](https://opensource.org/licenses/MIT)
174
-
175
- © 2016-present, [Elf-mousE](http://elf-mouse.me/)
176
-
177
- [balm-core-image]: https://img.shields.io/npm/v/balm-core.svg
178
- [balm-core-url]: https://npmjs.org/package/balm-core
179
- [balm-image]: https://img.shields.io/npm/v/balm.svg
180
- [balm-url]: https://npmjs.org/package/balm
181
- [license-image]: https://img.shields.io/npm/l/balm-core.svg?sanitize=true
182
- [license-url]: https://www.npmjs.com/package/balm-core
183
- [cover-image]: https://coveralls.io/repos/balmjs/balm/badge.svg
184
- [cover-url]: https://coveralls.io/r/balmjs/balm
185
- [balm-cli-image]: https://img.shields.io/npm/v/balm-cli.svg
186
- [balm-cli-url]: https://npmjs.org/package/balm-cli
187
- [balm-ui-lite-image]: https://img.shields.io/npm/v/balm-ui-lite.svg
188
- [balm-ui-lite-url]: https://npmjs.org/package/balm-ui-lite
189
- [balm-ui-image]: https://img.shields.io/npm/v/balm-ui.svg
190
- [balm-ui-url]: https://npmjs.org/package/balm-ui
191
- [balm-scroll-image]: https://img.shields.io/npm/v/balm-scroll.svg
192
- [balm-scroll-url]: https://npmjs.org/package/balm-scroll
193
- [balm-ui-pro-image]: https://badge.fury.io/js/balm-ui-pro.svg
194
- [balm-ui-pro-url]: https://npmjs.org/package/balm-ui-pro
195
- [balm-git-flow-image]: https://badge.fury.io/js/balm-git-flow.svg
196
- [balm-git-flow-url]: https://npmjs.org/package/balm-git-flow
package/index.d.ts DELETED
@@ -1,360 +0,0 @@
1
- export * from './types/vendors';
2
- export * from './types/globals';
3
- export * from './types/webworker';
4
- export * from './types/balm';
5
- export * from './types/gulp';
6
- export * from './types/node';
7
-
8
- export interface LooseObject {
9
- [key: string]: any;
10
- }
11
-
12
- export type DeepPartial<T> = {
13
- [P in keyof T]?: DeepPartial<T[P]>;
14
- };
15
-
16
- export interface BalmEnvObject {
17
- isProd: boolean;
18
- isTest: boolean;
19
- isDev: boolean;
20
- inSSR: boolean;
21
- isMP: boolean;
22
- inDesktopApp: boolean;
23
- }
24
-
25
- export interface BalmPath {
26
- base: string;
27
- html: string;
28
- css: string;
29
- js: string;
30
- img: string;
31
- font: string;
32
- media: string;
33
- }
34
-
35
- interface BalmStyles {
36
- extname: string;
37
- minify: boolean;
38
- atImportPaths: string[];
39
- entry: string | string[];
40
- options: object;
41
- sassOptions: object;
42
- lessOptions: object;
43
- postcssEnvOptions: object;
44
- postcssPlugins: object[];
45
- imageBasePath: string;
46
- sprites: string[];
47
- spriteRetina: boolean;
48
- spriteParams: object;
49
- }
50
-
51
- // Sass
52
- export type SassOptions = import('sass').Options<'sync'>;
53
- export type CompileResult = import('sass').CompileResult;
54
- export type LegacyOptions = import('sass').LegacyOptions<'sync'>;
55
- export type LegacyResult = import('sass').LegacyResult;
56
-
57
- // Webpack
58
- export type WebpackEntry = import('webpack').Entry;
59
- export type Configuration = import('webpack').Configuration;
60
- export type RuleSetRule = import('webpack').RuleSetRule;
61
-
62
- export interface BalmLoaders {
63
- js: boolean;
64
- css: boolean;
65
- html: boolean;
66
- asset: boolean;
67
- }
68
- export interface PostcssLoaderOptions {
69
- exec?: boolean;
70
- postcssOptions?: object | Function; // NOTE: `postcssOptions.plugins` is the same to `styles.postcssPlugins`
71
- sourceMap: string | boolean;
72
- }
73
-
74
- // Rollup
75
- export type RollupPlugin = import('rollup').Plugin;
76
- export type OutputPlugin = import('rollup').OutputPlugin;
77
- export type InputOption = import('rollup').InputOption;
78
- export type InputOptions = import('rollup').InputOptions;
79
- export type OutputOptions = import('rollup').OutputOptions;
80
- export type RollupOutput = import('rollup').RollupOutput;
81
- export type RollupBuild = import('rollup').RollupBuild;
82
-
83
- // Esbuild
84
- export type BuildOptions = import('esbuild').BuildOptions;
85
- export type TransformOptions = import('esbuild').TransformOptions;
86
- export type TransformResult = import('esbuild').TransformResult;
87
-
88
- // Bundler base
89
- export type BalmBundler = 'webpack' | 'rollup' | 'esbuild';
90
- export type MinifyOptions = import('terser').MinifyOptions;
91
- export type BalmEntry = string | string[] | WebpackEntry;
92
-
93
- export interface BalmScripts {
94
- // base
95
- bundler: BalmBundler;
96
- minify: boolean;
97
- minifyOptions: MinifyOptions;
98
- entry: BalmEntry;
99
- lint: boolean;
100
- // webpack
101
- library: string | object;
102
- loaders: RuleSetRule[];
103
- defaultLoaders: Partial<BalmLoaders>;
104
- includeJsResource: string[];
105
- useEsModule: boolean;
106
- babelLoaderOptions: object;
107
- postcssLoaderOptions: Partial<PostcssLoaderOptions>;
108
- htmlLoaderOptions: object;
109
- imageAssetType: string;
110
- imageInlineSizeLimit: number;
111
- extensions: string[];
112
- alias: object;
113
- plugins: object[];
114
- nodeEnv: object;
115
- injectHtml: boolean;
116
- htmlPluginOptions: object;
117
- extractCss: boolean;
118
- sourceMap: string | boolean;
119
- target: string | string[] | false;
120
- externals: string | string[] | object | Function | RegExp;
121
- stats: object | string;
122
- webpackOptions: Configuration;
123
- optimization: object;
124
- extractAllVendors: boolean;
125
- vendorName: string;
126
- ie8: boolean;
127
- // rollup
128
- inputOptions: Omit<InputOptions, 'acorn'>; // incompatible
129
- outputOptions: OutputOptions;
130
- // esbuild
131
- buildOptions: BuildOptions;
132
- useTransform: boolean;
133
- transformOptions: TransformOptions;
134
- // extra
135
- useCache?: boolean;
136
- }
137
-
138
- export interface BalmImagesPlugins {
139
- gif: boolean | Function;
140
- jpeg: boolean | Function;
141
- png: boolean | Function;
142
- svg: boolean | Function;
143
- }
144
-
145
- interface BalmImages {
146
- plugins: Partial<BalmImagesPlugins> | Function[];
147
- }
148
-
149
- export interface BalmAssetsPath extends BalmPath {
150
- static: string;
151
- }
152
-
153
- export interface BalmAssets extends Partial<BalmAssetsPath> {
154
- root: string;
155
- mainDir: string;
156
- subDir: string;
157
- buildDir: string;
158
- virtualDir: string;
159
- cache: boolean;
160
- options: object;
161
- includes: string[];
162
- excludes: string[];
163
- }
164
-
165
- export type BalmProxyOptions = import('http-proxy-middleware').Options;
166
-
167
- interface BalmServer {
168
- port: number;
169
- host: string | null;
170
- https: boolean | undefined;
171
- open: string | boolean;
172
- proxy: string | boolean | object;
173
- serveStatic: string[];
174
- next: Function;
175
- options: any;
176
- devOptions: object;
177
- hotOptions: object;
178
- proxyOptions: boolean | BalmProxyOptions | BalmProxyOptions[];
179
- historyOptions: boolean | object;
180
- middlewares: Function[] | object[];
181
- extraWatchFiles: string[];
182
- // extra
183
- useHMR?: boolean;
184
- }
185
-
186
- export interface BalmFtpConfig {
187
- host?: string;
188
- port?: number;
189
- username?: string;
190
- password?: string;
191
- remotePath?: string;
192
- dirMode?: string;
193
- fileMode?: string;
194
- }
195
-
196
- export interface BalmConfig {
197
- env: BalmEnvObject;
198
- workspace: string;
199
- inFrontend: boolean;
200
- useDefaults: boolean;
201
- roots: {
202
- source: string;
203
- tmp: string;
204
- target: string;
205
- };
206
- paths: {
207
- source: BalmPath;
208
- tmp: Omit<BalmPath, 'html'>;
209
- target: Omit<BalmPath, 'html'>;
210
- };
211
- html: {
212
- options: object;
213
- };
214
- styles: BalmStyles;
215
- scripts: BalmScripts;
216
- images: BalmImages;
217
- extras: {
218
- includes: string[];
219
- excludes: string[];
220
- };
221
- assets: BalmAssets;
222
- server: BalmServer;
223
- ftp: {
224
- options: BalmFtpConfig;
225
- watchFiles: string[];
226
- };
227
- pwa: {
228
- enabled: boolean;
229
- manifest: string;
230
- workboxSw: string;
231
- mode: string;
232
- options: object;
233
- swSrcFilename: string;
234
- swDestFilename: string;
235
- version: string;
236
- };
237
- logs: {
238
- level: number;
239
- formatOptions: object;
240
- };
241
- src: BalmPath;
242
- dest: BalmAssetsPath;
243
- }
244
-
245
- export interface BalmVendor {
246
- key: string;
247
- value: string[];
248
- }
249
-
250
- export interface RenameOptions {
251
- dirname?: string;
252
- prefix?: string;
253
- basename?: string;
254
- suffix?: string;
255
- extname?: string;
256
- }
257
-
258
- export interface HookOptions {
259
- src?: object;
260
- sass?: object;
261
- less?: object;
262
- terser?: MinifyOptions;
263
- rename?: string | Function | RenameOptions;
264
- ftp?: BalmFtpConfig;
265
- }
266
-
267
- export interface SpriteOptions {
268
- extname?: string;
269
- imageBasePath?: string;
270
- imageTarget?: string; // NOTE: overwrite `balm.config.paths.target.img`
271
- spriteRetina?: boolean;
272
- spriteParams?: object;
273
- }
274
-
275
- export interface ReplaceOptions {
276
- substr: string | RegExp;
277
- replacement: string | Function;
278
- }
279
-
280
- export interface TemplateOption {
281
- input: string;
282
- output: string;
283
- renameOptions: string | Function | RenameOptions;
284
- }
285
-
286
- export interface BalmError extends Error {
287
- code: string;
288
- details?: string;
289
- }
290
-
291
- interface BalmRecipe {
292
- env: BalmEnvObject;
293
- html: (input: string, output: string) => void;
294
- css: (input: string | string[], output: string) => void;
295
- sass: (
296
- input: string | string[],
297
- output: string,
298
- options?: HookOptions
299
- ) => void;
300
- less: (
301
- input: string | string[],
302
- output: string,
303
- options?: HookOptions
304
- ) => void;
305
- url: (input: string | string[], output: string) => void;
306
- webpack: (input: BalmEntry, output: string, options?: Configuration) => void;
307
- rollup: (input: InputOptions, output: OutputOptions) => void;
308
- esbuild: (
309
- input: string | string[],
310
- output: string,
311
- options?: BuildOptions | TransformOptions
312
- ) => void;
313
- jsmin: (
314
- input: string | string[],
315
- output: string,
316
- options?: HookOptions
317
- ) => void;
318
- copy: (
319
- input: string | string[],
320
- output: string,
321
- options?: HookOptions
322
- ) => void;
323
- remove: (paths: string | string[]) => void;
324
- version: (
325
- input: string | string[],
326
- output: string,
327
- assetsOptions?: object
328
- ) => void;
329
- serve: (handler: Function) => void;
330
- sprite: (
331
- input: string[],
332
- output: string,
333
- spriteOptions?: SpriteOptions
334
- ) => void;
335
- replace: (
336
- input: string | string[],
337
- output: string,
338
- options: ReplaceOptions | ReplaceOptions[]
339
- ) => void;
340
- publish: (
341
- input: string | TemplateOption[],
342
- output: string,
343
- renameOptions?: string | Function | RenameOptions
344
- ) => void;
345
- zip: (input: string | string[], output?: string, filename?: string) => void;
346
- ftp: (localFiles: string, options?: HookOptions) => void;
347
- generateSW: (pwaOptions: object) => void;
348
- injectManifest: (pwaOptions: object) => void;
349
- modernizr: () => void;
350
- }
351
-
352
- export type BalmRecipeFunction = (parameters: Partial<BalmRecipe>) => {};
353
-
354
- export interface Balm {
355
- config: Partial<Omit<BalmConfig, 'src' | 'dest'>>;
356
- beforeTask?: string | Function;
357
- afterTask?: string | Function;
358
- go: (recipe?: BalmRecipeFunction) => void;
359
- reset?: Function;
360
- }