@asd14/vblocks 5.4.0 → 6.0.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/README.md +28 -36
- package/bin/vblocks +120 -0
- package/bin/vblocks.d/build +145 -0
- package/bin/vblocks.d/eject +38 -0
- package/bin/vblocks.d/init +274 -0
- package/bin/vblocks.d/lib.sh +569 -0
- package/bin/vblocks.d/serve +100 -0
- package/bin/vblocks.d/vblocks.sh +92 -0
- package/bin/vblocks.d/webpack.sh +130 -0
- package/package.json +2 -2
- package/src/types/client.d.ts +19 -0
- package/src/webpack.config.js +32 -21
- package/template/xyflow/app/src/diagram.tsx +0 -2
- package/bin/vblocks.sh +0 -685
- package/template/xyflow/app/src/ui/zoom-level.tsx +0 -29
package/README.md
CHANGED
|
@@ -258,7 +258,7 @@ import { Component } from "@self/components"
|
|
|
258
258
|
|
|
259
259
|
> [!NOTE]
|
|
260
260
|
> The [client types](src/types/client.d.ts) declare `.css`, image and font
|
|
261
|
-
> imports
|
|
261
|
+
> imports.
|
|
262
262
|
|
|
263
263
|
### Replace a default config
|
|
264
264
|
|
|
@@ -288,11 +288,6 @@ Each config in your app folder replaces the default of the same name:
|
|
|
288
288
|
> - `.swcrc -> jsc.transform.react.refresh`: VBlocks adds the React Refresh
|
|
289
289
|
> transform when `serve` runs in `development` mode
|
|
290
290
|
|
|
291
|
-
> [!NOTE]
|
|
292
|
-
> VBlocks passes [`build --single-file`](#vblocks-build) and
|
|
293
|
-
> [`serve --analyze`](#vblocks-serve) to your `webpack.config.js` as
|
|
294
|
-
> `env.single` and `env.analyze`.
|
|
295
|
-
|
|
296
291
|
### Style with Tailwind
|
|
297
292
|
|
|
298
293
|
VBlocks does not include Tailwind. Add it through a `postcss.config.js` in your
|
|
@@ -408,8 +403,8 @@ vblocks init <directory>
|
|
|
408
403
|
- `plumbing`: `package.json`, `.gitignore`
|
|
409
404
|
- `app`: `src/`, `tsconfig.json` and the template's configs. `init` adds the
|
|
410
405
|
template's dependencies to the `package.json` of the
|
|
411
|
-
[project folder](#vocabulary), the
|
|
412
|
-
`package.json
|
|
406
|
+
[project folder](#vocabulary), the parent of `<directory>`. Without a
|
|
407
|
+
`package.json` there, `init` fails
|
|
413
408
|
|
|
414
409
|
#### `vblocks serve`
|
|
415
410
|
|
|
@@ -426,7 +421,7 @@ vblocks serve
|
|
|
426
421
|
[--prefix <directory>]
|
|
427
422
|
[--analyze]
|
|
428
423
|
[--log-level <error|warn|info|verbose>]
|
|
429
|
-
[<webpack option>...]
|
|
424
|
+
[-- <webpack option>...]
|
|
430
425
|
```
|
|
431
426
|
|
|
432
427
|
- `--mode` (default: `development`)
|
|
@@ -437,10 +432,11 @@ vblocks serve
|
|
|
437
432
|
- `--analyze`
|
|
438
433
|
- Run the bundle analyzer, on a free port
|
|
439
434
|
- `--log-level` (default: `warn`)
|
|
440
|
-
- How much Webpack
|
|
441
|
-
-
|
|
442
|
-
- Any
|
|
443
|
-
|
|
435
|
+
- How much Webpack and its development server print
|
|
436
|
+
- `-- <webpack option>...`
|
|
437
|
+
- Any [`webpack serve`](https://webpack.js.org/api/cli/) option
|
|
438
|
+
- `serve` passes each one to Webpack unchanged
|
|
439
|
+
- eg. `-- --host 0.0.0.0`, to listen on the network
|
|
444
440
|
|
|
445
441
|
#### `vblocks build`
|
|
446
442
|
|
|
@@ -452,7 +448,7 @@ By default, `build`:
|
|
|
452
448
|
- Writes a `react` chunk, and a `vendors` chunk when your other dependencies
|
|
453
449
|
total over 20 KB (10 KB in `development`)
|
|
454
450
|
- Inlines `jpg`, `gif`, `png` and `svg` files up to 10 KB
|
|
455
|
-
- Writes larger to `dist/` with content-hashed names
|
|
451
|
+
- Writes larger images to `dist/` with content-hashed names
|
|
456
452
|
- Writes `woff`, `woff2`, `ttf` and `eot` files to `dist/fonts/`
|
|
457
453
|
- Copies `src/public/favicon.svg` and `src/public/robots.txt` of your app, or
|
|
458
454
|
the defaults of VBlocks
|
|
@@ -463,7 +459,7 @@ vblocks build
|
|
|
463
459
|
[--prefix <directory>]
|
|
464
460
|
[--single-file]
|
|
465
461
|
[--log-level <error|warn|info|verbose>]
|
|
466
|
-
[<webpack option>...]
|
|
462
|
+
[-- <webpack option>...]
|
|
467
463
|
```
|
|
468
464
|
|
|
469
465
|
- `--mode` (default: `production`)
|
|
@@ -479,10 +475,11 @@ vblocks build
|
|
|
479
475
|
- Keep the route in the URL hash
|
|
480
476
|
- On `file://`, `history.pushState` to another path throws
|
|
481
477
|
- `--log-level` (default: `warn`)
|
|
482
|
-
- How much Webpack
|
|
483
|
-
-
|
|
484
|
-
- Any
|
|
485
|
-
|
|
478
|
+
- How much Webpack prints
|
|
479
|
+
- `-- <webpack option>...`
|
|
480
|
+
- Any [`webpack build`](https://webpack.js.org/api/cli/) option
|
|
481
|
+
- `build` passes each one to Webpack unchanged
|
|
482
|
+
- eg. `-- --devtool source-map`, to write source maps
|
|
486
483
|
|
|
487
484
|
#### `vblocks eject`
|
|
488
485
|
|
|
@@ -506,37 +503,35 @@ npx vblocks eject swc > .swcrc
|
|
|
506
503
|
|
|
507
504
|
### Templates
|
|
508
505
|
|
|
509
|
-
|
|
510
|
-
template adds its own files, and sets the `<title>` of `src/index.html`. A
|
|
511
|
-
template's file replaces the common one of the same path, eg. `xyflow` has its
|
|
512
|
-
own `src/index.css`.
|
|
506
|
+
All templates scaffold `src/index.html`, `src/index.css` and `tsconfig.json`.
|
|
513
507
|
|
|
514
508
|
#### `plain`
|
|
515
509
|
|
|
516
|
-
`src/index.tsx
|
|
510
|
+
"Hello World!" in `src/index.tsx`.
|
|
511
|
+
|
|
512
|
+
- Adds no packages
|
|
517
513
|
|
|
518
514
|
#### `xyflow`
|
|
519
515
|
|
|
520
|
-
One diagram, and a details panel for the selected node or edge.
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
516
|
+
One diagram, and a details panel for the selected node or edge.
|
|
517
|
+
|
|
518
|
+
- Adds `@xyflow/react`, `tailwindcss` and `@tailwindcss/postcss` to the
|
|
519
|
+
`package.json` of the project folder
|
|
520
|
+
- Writes a `postcss.config.js` that configures Tailwind
|
|
524
521
|
|
|
525
522
|
```text
|
|
526
523
|
src/
|
|
527
524
|
├── index.tsx # the layout: header, diagram, details panel, the selected id
|
|
528
525
|
├── diagram.tsx # the nodes and edges, placed and sized in grid cells
|
|
529
526
|
├── details.tsx # the panel for the selected node or edge
|
|
530
|
-
├── ui/zoom-level.tsx # the zoom level, and a Reset to 100%
|
|
531
527
|
└── utils/grid.ts # CELL_SIZE and toPixels
|
|
532
528
|
```
|
|
533
529
|
|
|
534
|
-
To show another topic, rewrite `diagram.tsx` and `details.tsx`.
|
|
535
|
-
|
|
536
530
|
#### `xyflow-tabs`
|
|
537
531
|
|
|
538
|
-
One tab per diagram, each with its own details panel.
|
|
539
|
-
|
|
532
|
+
One tab per diagram, each with its own details panel.
|
|
533
|
+
|
|
534
|
+
- Adds the same packages and `postcss.config.js` as `xyflow`
|
|
540
535
|
|
|
541
536
|
```text
|
|
542
537
|
src/
|
|
@@ -550,9 +545,6 @@ src/
|
|
|
550
545
|
└── utils/grid.ts # CELL_SIZE and toPixels
|
|
551
546
|
```
|
|
552
547
|
|
|
553
|
-
To add a tab, add a folder in `pages/` and add it to the tab list in
|
|
554
|
-
`index.tsx`.
|
|
555
|
-
|
|
556
548
|
## License
|
|
557
549
|
|
|
558
550
|
MIT
|
package/bin/vblocks
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
set -eu
|
|
4
|
+
|
|
5
|
+
# NAME
|
|
6
|
+
# vblocks - Write a project or an app, then serve or build it with Webpack
|
|
7
|
+
#
|
|
8
|
+
# SYNOPSIS
|
|
9
|
+
# vblocks init <directory>
|
|
10
|
+
# [--template <plain|xyflow|xyflow-tabs>]
|
|
11
|
+
# [--only <app|plumbing>]
|
|
12
|
+
# vblocks serve
|
|
13
|
+
# [--mode <development|production>]
|
|
14
|
+
# [--prefix <directory>]
|
|
15
|
+
# [--analyze]
|
|
16
|
+
# [--log-level <error|warn|info|verbose>]
|
|
17
|
+
# [-- <webpack option>...]
|
|
18
|
+
# vblocks build
|
|
19
|
+
# [--mode <development|production>]
|
|
20
|
+
# [--prefix <directory>]
|
|
21
|
+
# [--single-file]
|
|
22
|
+
# [--log-level <error|warn|info|verbose>]
|
|
23
|
+
# [-- <webpack option>...]
|
|
24
|
+
# vblocks eject <webpack|postcss|swc>
|
|
25
|
+
# vblocks -h | --help
|
|
26
|
+
#
|
|
27
|
+
# DESCRIPTION
|
|
28
|
+
# The app folder holds src/index.tsx and src/index.html. A config in it,
|
|
29
|
+
# webpack.config.js, postcss.config.js or .swcrc, replaces the VBlocks
|
|
30
|
+
# default of the same name.
|
|
31
|
+
#
|
|
32
|
+
# init Write a template into <directory>, which must be missing or
|
|
33
|
+
# empty. A template has two parts: the plumbing, which holds
|
|
34
|
+
# the files of the project folder, and the app. Without --only,
|
|
35
|
+
# write both.
|
|
36
|
+
# After each part, run its post-init hooks in <directory>.
|
|
37
|
+
# Print each file it adds, updates or drops, then the next
|
|
38
|
+
# steps.
|
|
39
|
+
# serve Start the development server
|
|
40
|
+
# build Build the app into dist/ in the app folder. Print each file
|
|
41
|
+
# in dist/, its size and the total
|
|
42
|
+
# eject Print a default config, to save in the app folder
|
|
43
|
+
#
|
|
44
|
+
# serve and build pass every option after -- to Webpack, unchanged.
|
|
45
|
+
#
|
|
46
|
+
# OPTIONS
|
|
47
|
+
# --template <name> init: plain, xyflow or xyflow-tabs (default: plain)
|
|
48
|
+
# --only <app|plumbing> init: write only the app or only the plumbing.
|
|
49
|
+
# With app, init adds the app's dependencies to
|
|
50
|
+
# the package.json in the parent folder of
|
|
51
|
+
# <directory>. Without that file, init exits 3
|
|
52
|
+
# --mode <mode> serve, build: the Webpack mode, development or
|
|
53
|
+
# production (default: development for serve,
|
|
54
|
+
# production for build)
|
|
55
|
+
# --prefix <directory> serve, build: the app folder (default: the
|
|
56
|
+
# current folder)
|
|
57
|
+
# --single-file build: one standalone dist/index.html, every
|
|
58
|
+
# asset inlined
|
|
59
|
+
# --analyze serve: run the bundle analyzer, on a free port
|
|
60
|
+
# --log-level <level> serve, build: how much Webpack and its dev server
|
|
61
|
+
# print: error, warn, info or verbose (default:
|
|
62
|
+
# warn)
|
|
63
|
+
# -h, --help Print this help
|
|
64
|
+
#
|
|
65
|
+
# ENVIRONMENT
|
|
66
|
+
# NO_COLOR When non-empty, print without color, the tool icons or the
|
|
67
|
+
# header
|
|
68
|
+
#
|
|
69
|
+
# EXAMPLE
|
|
70
|
+
# npx @asd14/vblocks init my-app
|
|
71
|
+
# npx @asd14/vblocks init demos --only plumbing
|
|
72
|
+
# npx @asd14/vblocks init demos/flow --template xyflow --only app
|
|
73
|
+
# cd demos && npx vblocks build --prefix flow --single-file
|
|
74
|
+
# npx vblocks serve -- --host 0.0.0.0
|
|
75
|
+
# npx vblocks eject postcss > postcss.config.js
|
|
76
|
+
#
|
|
77
|
+
# EXIT CODES
|
|
78
|
+
# 0 Done
|
|
79
|
+
# 2 Invalid usage, or Webpack rejected an option or the config
|
|
80
|
+
# 3 Could not run: a missing tool or parent package.json, a folder init
|
|
81
|
+
# could not add, or a failed copy, hook or Webpack run
|
|
82
|
+
#
|
|
83
|
+
# SEE ALSO
|
|
84
|
+
# node, npm, webpack
|
|
85
|
+
|
|
86
|
+
# npm links the command to this file, so "$0" names the link. realpath follows
|
|
87
|
+
# it to the package, where vblocks.d/ holds the commands
|
|
88
|
+
_SCRIPT_DIR="$(dirname "$(realpath "$0")")/vblocks.d"
|
|
89
|
+
# shellcheck source=vblocks.d/vblocks.sh
|
|
90
|
+
. "$_SCRIPT_DIR/vblocks.sh"
|
|
91
|
+
|
|
92
|
+
# ╭───
|
|
93
|
+
# │ Bootstrap
|
|
94
|
+
# ╰───
|
|
95
|
+
|
|
96
|
+
case "${1:-}" in
|
|
97
|
+
-h | --help)
|
|
98
|
+
_show_help "$0"
|
|
99
|
+
exit 0
|
|
100
|
+
;;
|
|
101
|
+
"")
|
|
102
|
+
_show_help "$0" >&2
|
|
103
|
+
exit 2
|
|
104
|
+
;;
|
|
105
|
+
esac
|
|
106
|
+
|
|
107
|
+
# ╭───
|
|
108
|
+
# │ Main
|
|
109
|
+
# ╰───
|
|
110
|
+
|
|
111
|
+
_COMMAND=$1
|
|
112
|
+
shift
|
|
113
|
+
|
|
114
|
+
case "$_COMMAND" in
|
|
115
|
+
init | serve | build | eject) ;;
|
|
116
|
+
*) _fail 2 -v command "$_COMMAND" -v available_commands "init,serve,build,eject" "Unknown command" ;;
|
|
117
|
+
esac
|
|
118
|
+
|
|
119
|
+
# sh runs the command file, whatever mode npm gave it
|
|
120
|
+
exec sh "$_SCRIPT_DIR/$_COMMAND" "$@"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# vblocks build [OPTIONS] [-- <webpack option>...]
|
|
4
|
+
#
|
|
5
|
+
# Build the app into dist/ in the app folder, then print
|
|
6
|
+
# each file in it. vblocks runs this file. Never call it directly.
|
|
7
|
+
|
|
8
|
+
set -eu
|
|
9
|
+
|
|
10
|
+
_SCRIPT_DIR=$(dirname "$0")
|
|
11
|
+
# shellcheck source=vblocks.sh
|
|
12
|
+
. "$_SCRIPT_DIR/vblocks.sh"
|
|
13
|
+
# shellcheck source=webpack.sh
|
|
14
|
+
. "$_SCRIPT_DIR/webpack.sh"
|
|
15
|
+
|
|
16
|
+
# ╭───
|
|
17
|
+
# │ Settings
|
|
18
|
+
# ╰───
|
|
19
|
+
|
|
20
|
+
_PREFIX_DIR="" # --prefix, the app folder
|
|
21
|
+
_MODE="production" # --mode: development or production
|
|
22
|
+
_LOG_LEVEL="warn" # --log-level: error, warn, info or verbose
|
|
23
|
+
_IS_SINGLE_FILE="" # --single-file, "true" or ""
|
|
24
|
+
|
|
25
|
+
# ╭───
|
|
26
|
+
# │ Domain primitives
|
|
27
|
+
# ╰───
|
|
28
|
+
|
|
29
|
+
# _print_build_files <app-dir>
|
|
30
|
+
#
|
|
31
|
+
# Print each file in the dist/ of <app-dir> as $APP_DIR/dist/..., a tab and its
|
|
32
|
+
# size, then the total size. Webpack empties dist/ before each build, so every
|
|
33
|
+
# file there is from the last build.
|
|
34
|
+
_print_build_files() {
|
|
35
|
+
# An ejected config can write elsewhere
|
|
36
|
+
[ -d "$1/dist" ] || return 0
|
|
37
|
+
|
|
38
|
+
(cd -- "$1/dist" && find . -type f | LC_ALL=C sort) \
|
|
39
|
+
| while IFS= read -r pbf_file; do
|
|
40
|
+
printf '%s\t%s\n' "$(wc -c <"$1/dist/$pbf_file")" "${pbf_file#./}"
|
|
41
|
+
done \
|
|
42
|
+
| awk -F '\t' -v gray="$_GRAY" -v bold="$_BOLD" -v reset="$_RESET" '
|
|
43
|
+
function format_size(bytes) {
|
|
44
|
+
if (bytes < 1024) return bytes " B"
|
|
45
|
+
if (bytes < 1024 * 1024) return sprintf("%.1f KiB", bytes / 1024)
|
|
46
|
+
return sprintf("%.1f MiB", bytes / 1024 / 1024)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
total += $1
|
|
51
|
+
printf "$APP_DIR/dist/%s\t%s%s%s\n", $2, gray, format_size($1), reset
|
|
52
|
+
}
|
|
53
|
+
END { printf "\n%sTotal%s\t%s\n", bold, reset, format_size(total) }
|
|
54
|
+
'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# ╭───
|
|
58
|
+
# │ Flags and positionals
|
|
59
|
+
# ╰───
|
|
60
|
+
|
|
61
|
+
while [ "$#" -gt 0 ]; do
|
|
62
|
+
case "$1" in
|
|
63
|
+
--prefix)
|
|
64
|
+
[ "$#" -lt 2 ] && _fail 2 "--prefix needs a folder"
|
|
65
|
+
_PREFIX_DIR=$2
|
|
66
|
+
shift 2
|
|
67
|
+
;;
|
|
68
|
+
--mode)
|
|
69
|
+
_guard_mode "${2:-}"
|
|
70
|
+
_MODE=$2
|
|
71
|
+
shift 2
|
|
72
|
+
;;
|
|
73
|
+
--log-level)
|
|
74
|
+
_guard_log_level "${2:-}"
|
|
75
|
+
_LOG_LEVEL=$2
|
|
76
|
+
shift 2
|
|
77
|
+
;;
|
|
78
|
+
--single-file | --single)
|
|
79
|
+
_IS_SINGLE_FILE="true"
|
|
80
|
+
shift
|
|
81
|
+
;;
|
|
82
|
+
--analyze)
|
|
83
|
+
_fail 2 "--analyze works only with serve"
|
|
84
|
+
;;
|
|
85
|
+
--)
|
|
86
|
+
shift
|
|
87
|
+
break
|
|
88
|
+
;;
|
|
89
|
+
-?*)
|
|
90
|
+
_fail 2 -v flag "$1" "Unknown flag. For Webpack options, place them after --"
|
|
91
|
+
;;
|
|
92
|
+
*)
|
|
93
|
+
_fail 2 -v argument "$1" "build takes no positional"
|
|
94
|
+
;;
|
|
95
|
+
esac
|
|
96
|
+
done
|
|
97
|
+
|
|
98
|
+
if [ -n "$_PREFIX_DIR" ] && [ ! -d "$_PREFIX_DIR" ]; then
|
|
99
|
+
_fail 2 -v prefix "$_PREFIX_DIR" "--prefix is not a folder"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# node runs webpack-cli
|
|
103
|
+
_require_cmd node
|
|
104
|
+
_export_version
|
|
105
|
+
|
|
106
|
+
# ╭───
|
|
107
|
+
# │ Main
|
|
108
|
+
# ╰───
|
|
109
|
+
|
|
110
|
+
_APP_DIR=$(cd -- "${_PREFIX_DIR:-.}" && pwd)
|
|
111
|
+
_WEBPACK_CONFIG=$(_pick_config "$_APP_DIR" webpack.config.js)
|
|
112
|
+
_POSTCSS_CONFIG=$(_pick_config "$_APP_DIR" postcss.config.js)
|
|
113
|
+
_SWC_CONFIG=$(_pick_config "$_APP_DIR" .swcrc)
|
|
114
|
+
# A single file has no robots.txt next to it. Webpack drops an --env with an
|
|
115
|
+
# empty value, so the config gets no robotsPath
|
|
116
|
+
_ROBOTS_FILE=""
|
|
117
|
+
if [ -z "$_IS_SINGLE_FILE" ]; then
|
|
118
|
+
_ROBOTS_FILE=$(_pick_file \
|
|
119
|
+
"$_APP_DIR/src/public/robots.txt" "$_VB_DIR/src/public/robots.txt")
|
|
120
|
+
fi
|
|
121
|
+
_FAVICON_FILE=$(_pick_file \
|
|
122
|
+
"$_APP_DIR/src/public/favicon.svg" "$_VB_DIR/src/public/favicon.svg")
|
|
123
|
+
|
|
124
|
+
_ARTIFACT="SPA bundle"
|
|
125
|
+
if [ -n "$_IS_SINGLE_FILE" ]; then
|
|
126
|
+
_ARTIFACT="single file"
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
_print_header "$VB_VERSION" "${_BOLD}build${_RESET}: $_MODE, $_ARTIFACT" >&2
|
|
130
|
+
_print_summary "$_APP_DIR" "$_WEBPACK_CONFIG" "$_POSTCSS_CONFIG" "$_SWC_CONFIG" \
|
|
131
|
+
"$_ROBOTS_FILE" "$_FAVICON_FILE"
|
|
132
|
+
|
|
133
|
+
# The default Webpack config reads env.single. An ejected config supports
|
|
134
|
+
# --single-file only if it reads env.single too
|
|
135
|
+
_run_webpack build "$_WEBPACK_CONFIG" \
|
|
136
|
+
--env "entryDir=$_APP_DIR" \
|
|
137
|
+
--env "postcssConfigPath=$_POSTCSS_CONFIG" \
|
|
138
|
+
--env "swcConfigPath=$_SWC_CONFIG" \
|
|
139
|
+
--env "robotsPath=$_ROBOTS_FILE" \
|
|
140
|
+
--env "faviconPath=$_FAVICON_FILE" \
|
|
141
|
+
--env "logLevel=$_LOG_LEVEL" \
|
|
142
|
+
--mode "$_MODE" ${_IS_SINGLE_FILE:+--env single} "$@"
|
|
143
|
+
printf '\n'
|
|
144
|
+
_print_build_files "$_APP_DIR"
|
|
145
|
+
exit 0
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
# vblocks eject <webpack|postcss|swc>
|
|
4
|
+
#
|
|
5
|
+
# Print a default config, to save in the app folder. vblocks runs this file.
|
|
6
|
+
# Never call it directly.
|
|
7
|
+
|
|
8
|
+
set -eu
|
|
9
|
+
|
|
10
|
+
_SCRIPT_DIR=$(dirname "$0")
|
|
11
|
+
# shellcheck source=vblocks.sh
|
|
12
|
+
. "$_SCRIPT_DIR/vblocks.sh"
|
|
13
|
+
|
|
14
|
+
# ╭───
|
|
15
|
+
# │ Settings
|
|
16
|
+
# ╰───
|
|
17
|
+
|
|
18
|
+
_EJECT_CONFIG="" # eject <config>
|
|
19
|
+
|
|
20
|
+
# ╭───
|
|
21
|
+
# │ Flags and positionals
|
|
22
|
+
# ╰───
|
|
23
|
+
|
|
24
|
+
[ "$#" -ne 1 ] && _fail 2 -v available_configs "webpack,postcss,swc" "eject needs one config"
|
|
25
|
+
|
|
26
|
+
case "$1" in
|
|
27
|
+
webpack) _EJECT_CONFIG="webpack.config.js" ;;
|
|
28
|
+
postcss) _EJECT_CONFIG="postcss.config.js" ;;
|
|
29
|
+
swc) _EJECT_CONFIG=".swcrc" ;;
|
|
30
|
+
*) _fail 2 -v config "$1" -v available_configs "webpack,postcss,swc" "Unknown config" ;;
|
|
31
|
+
esac
|
|
32
|
+
|
|
33
|
+
# ╭───
|
|
34
|
+
# │ Main
|
|
35
|
+
# ╰───
|
|
36
|
+
|
|
37
|
+
cat -- "$_VB_DIR/src/$_EJECT_CONFIG"
|
|
38
|
+
exit 0
|