-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
build.sh
executable file
·153 lines (140 loc) · 5 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env bash
set -e
BV_VERSION=$(node -p "require('./package.json').version")
BV_BANNER=$(node -p "require('./scripts/banner')")
echo "Building BootstrapVue ${BV_VERSION}"
echo ''
echo 'Generating icon source files...'
node -r esm scripts/create-icons.js || exit 1
echo 'done.'
echo ''
echo 'Checking plugin metadata...'
node -r esm scripts/check-plugin-meta.js || exit 1
echo 'Done.'
echo ''
# Cleanup
rm -rf dist esm
echo 'Compile JS...'
rollup -c scripts/rollup.config.js
echo 'Done.'
echo ''
echo 'Compiling ESM modular build...'
NODE_ENV=esm babel src \
--out-dir esm \
--ignore 'src/**/*.spec.js' \
--ignore 'src/browser.js' \
--ignore 'src/browser-icons.js' \
--ignore 'src/icons-only.js'
echo "${BV_BANNER}" | cat - esm/index.js > esm/tmp.js && mv -f esm/tmp.js esm/index.js
echo 'Done.'
echo ''
echo 'Minify JS...'
# We instruct terser to preserve our `Bv*Event` class names and
# safe types (i.e. `Element`, etc) when mangling top level names
terser dist/bootstrap-vue.js \
--compress typeofs=false \
--mangle reserved=['BvEvent','BvModalEvent','Element','HTMLElement','SVGElement'] \
--toplevel \
--keep-classnames \
--comments "/^!/" \
--source-map "content=dist/bootstrap-vue.js.map,includeSources,url=bootstrap-vue.min.js.map" \
--output dist/bootstrap-vue.min.js
terser dist/bootstrap-vue-icons.js \
--compress typeofs=false \
--mangle reserved=['BvEvent','BvModalEvent','Element','HTMLElement','SVGElement'] \
--toplevel \
--keep-classnames \
--comments "/^!/" \
--source-map "content=dist/bootstrap-vue-icons.js.map,includeSources,url=bootstrap-vue-icons.min.js.map" \
--output dist/bootstrap-vue-icons.min.js
terser dist/bootstrap-vue.common.js \
--compress typeofs=false \
--mangle reserved=['BvEvent','BvModalEvent','Element','HTMLElement','SVGElement'] \
--toplevel \
--keep-classnames \
--comments "/^!/" \
--source-map "content=dist/bootstrap-vue.common.js.map,includeSources,url=bootstrap-vue.common.min.js.map" \
--output dist/bootstrap-vue.common.min.js
terser dist/bootstrap-vue-icons.common.js \
--compress typeofs=false \
--mangle reserved=['BvEvent','BvModalEvent','Element','HTMLElement','SVGElement'] \
--toplevel \
--keep-classnames \
--comments "/^!/" \
--source-map "content=dist/bootstrap-vue-icons.common.js.map,includeSources,url=bootstrap-vue-icons.common.min.js.map" \
--output dist/bootstrap-vue-icons.common.min.js
terser dist/bootstrap-vue.esm.js \
--compress typeofs=false \
--mangle reserved=['BvEvent','BvModalEvent','Element','HTMLElement','SVGElement'] \
--toplevel \
--keep-classnames \
--comments "/^!/" \
--source-map "content=dist/bootstrap-vue.esm.js.map,includeSources,url=bootstrap-vue.esm.min.js.map" \
--output dist/bootstrap-vue.esm.min.js
terser dist/bootstrap-vue-icons.esm.js \
--compress typeofs=false \
--mangle reserved=['BvEvent','BvModalEvent','Element','HTMLElement','SVGElement'] \
--toplevel \
--keep-classnames \
--comments "/^!/" \
--source-map "content=dist/bootstrap-vue-icons.esm.js.map,includeSources,url=bootstrap-vue-icons.esm.min.js.map" \
--output dist/bootstrap-vue-icons.esm.min.js
echo 'Done.'
echo ''
echo 'Compile SCSS...'
# Complete BootstrapVue CSS
node-sass --output-style expanded \
--source-map true \
--source-map-contents true \
--precision 6 \
scripts/index.scss \
dist/bootstrap-vue.css
postcss --config scripts/postcss.config.js \
--replace dist/bootstrap-vue.css
# BootstrapVue Icons only CSS
node-sass --output-style expanded \
--source-map true \
--source-map-contents true \
--precision 6 \
scripts/icons.scss \
dist/bootstrap-vue-icons.css
postcss --config scripts/postcss.config.js \
--replace dist/bootstrap-vue-icons.css
echo 'Done.'
echo ''
echo 'Minify CSS...'
# Complete BootstrapVue CSS
cleancss --level 1 \
--format breaksWith=lf \
--source-map \
--source-map-inline-sources \
--output dist/bootstrap-vue.min.css \
dist/bootstrap-vue.css
# Icons only CSS
cleancss --level 1 \
--format breaksWith=lf \
--source-map \
--source-map-inline-sources \
--output dist/bootstrap-vue-icons.min.css \
dist/bootstrap-vue-icons.css
echo 'Done.'
echo ''
echo 'Copying types from src/ to esm/ ...'
# This may no longer be needed, as all exports are at top level now.
#
# There must be a better way to do this
# The following does not preserve the paths
# shopt -s globstar
# cp src/**/*.d.ts es
#
# So we resort to a find with exec
cd src
find . -type f -name '*.d.ts' -exec cp {} ../esm/{} ';'
cd ..
echo 'Done.'
echo ''
echo 'Building IDE auto-complete helper files...'
node -r esm scripts/create-web-types.js || exit 1
echo 'Done.'
echo ''
echo 'Done building assets.'