forked from alexeagle/closure-compiler-angular-bundling
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_closure.sh
executable file
·59 lines (48 loc) · 2.02 KB
/
build_closure.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
OPTS=(
"--language_in=ES6_STRICT"
"--language_out=ES5"
"--compilation_level=ADVANCED_OPTIMIZATIONS"
"--js_output_file=dist/bundle.js"
"--create_source_map=%outname%.map"
"--variable_renaming_report=dist/variable_renaming_report"
"--property_renaming_report=dist/property_renaming_report"
"--warning_level=QUIET"
# Don't include ES6 polyfills
"--rewrite_polyfills=false"
# List of path prefixes to be removed from ES6 & CommonJS modules.
"--js_module_root=node_modules"
"--js_module_root=vendor"
# Uncomment for easier debugging
#"--formatting=PRETTY_PRINT"
#"--debug"
# Include zone.js as externs rather than the source code.
# Allows us to use --dependency_mode=STRICT below.
# Otherwise the zone.js file is not imported anywhere and gets dropped.
# See index.html
#node_modules/zone.js/dist/zone.js
"vendor/zone_externs.js"
$(find vendor/rxjs -name *.js)
node_modules/@angular/{core,common,compiler,platform-browser,router,forms}/index.js
$(find node_modules/@angular/{core,common,compiler,platform-browser,router,forms}/src -name *.js)
built/node_modules/@angular/{common,router,forms}/src/directives/*.js
built/node_modules/@angular/forms/src/directives/reactive_directives/*.js
"built/src/*.js"
built/src/components/{grid,treeview,dynamic-form,input-controls,two-way-binding,insertion-sort}/*.js
# Trim files not imported (transitively) from bootstrap.js
"--entry_point=./built/src/bootstrap"
"--dependency_mode=STRICT"
"--output_manifest=dist/manifest.MF"
)
JVM_ARGS=""
# To attach a remote debugger:
#JVM_ARGS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
set -ex
java $JVM_ARGS -jar node_modules/google-closure-compiler/compiler.jar $(echo ${OPTS[*]})
# measure the sizes of scripts the user will need to load
for script in dist/bundle.js node_modules/zone.js/dist/zone.min.js; do
gzip --keep -f $script
# requires brotli
# on Mac: brew install brotli
bro --force --quality 10 --input $script --output $script.brotli
ls -alH ${script}*
done