@@ -95,10 +95,84 @@ task :concat => :init do
95
95
end
96
96
97
97
98
+ desc 'Minify source files into angular.min.js'
99
+ task :minify_angular => [ :init ] do
100
+ min_path = path_to ( 'angular.min.js' )
101
+
102
+ angular_prefix = %x(cat src/angular.prefix)
103
+ angular_suffix = %x(cat src/angular.suffix)
104
+
105
+ %x(java \
106
+ #{ java32flags ( ) } \
107
+ -jar lib/closure-compiler/compiler.jar \
108
+ --compilation_level SIMPLE_OPTIMIZATIONS \
109
+ --language_in ECMASCRIPT5_STRICT \
110
+ --warning_level VERBOSE \
111
+ --externs lib/externs/json.js \
112
+ --jscomp_off nonStandardJsDocs \
113
+ --jscomp_error ambiguousFunctionDecl \
114
+ --jscomp_error checkRegExp \
115
+ --jscomp_error checkTypes \
116
+ --jscomp_error checkVars \
117
+ --jscomp_error const \
118
+ --jscomp_error constantProperty \
119
+ --jscomp_error deprecated \
120
+ --jscomp_error duplicateMessage \
121
+ --jscomp_error es5Strict \
122
+ --jscomp_error externsValidation \
123
+ --jscomp_error globalThis \
124
+ --jscomp_error internetExplorerChecks \
125
+ --jscomp_error invalidCasts \
126
+ --jscomp_error misplacedTypeAnnotation \
127
+ --jscomp_error missingProperties \
128
+ --jscomp_error suspiciousCode \
129
+ --jscomp_error strictModuleDepCheck \
130
+ --jscomp_error typeInvalidation \
131
+ --jscomp_error undefinedNames \
132
+ --jscomp_error undefinedVars \
133
+ --jscomp_error unknownDefines \
134
+ --jscomp_error uselessCode \
135
+ --jscomp_error visibility \
136
+ --output_wrapper '#{ angular_prefix } %output% #{ angular_suffix } ' \
137
+ --js #{ files [ 'angularSrc' ] . flatten . join ( " \\ \n --js " ) } \
138
+ --js_output_file #{ min_path } )
139
+
140
+ rewrite_file ( min_path ) do |content |
141
+ content . gsub! ( '"NG_VERSION_FULL"' , NG_VERSION . full ) .
142
+ gsub! ( '"NG_VERSION_MAJOR"' , NG_VERSION . major ) .
143
+ gsub! ( '"NG_VERSION_MINOR"' , NG_VERSION . minor ) .
144
+ gsub! ( '"NG_VERSION_DOT"' , NG_VERSION . dot ) .
145
+ gsub! ( '"NG_VERSION_CODENAME"' , NG_VERSION . codename ) .
146
+ gsub! ( /\s *['"]use strict['"];?\s */ , '' ) . # remove all file-specific strict mode flags
147
+ sub! ( /\( function\( [^)]*\) \s *\{ / , "\\ 0\n 'use strict';" ) # add single strict mode flag
148
+ end
149
+ end
150
+
151
+
152
+ desc 'Double-minify angular.min.js into angular.min.js'
153
+ task :minify_angular2 => [ :minify_angular ] do
154
+ # We double minify to rename free floating fns in angular closure, this will go away
155
+ # when we switch to namespaces
156
+
157
+ input_path = path_to ( 'angular.min.js' )
158
+ output_path = path_to ( 'angular.min2.js' )
159
+
160
+ %x(java \
161
+ #{ java32flags ( ) } \
162
+ -jar lib/closure-compiler/compiler.jar \
163
+ --compilation_level SIMPLE_OPTIMIZATIONS \
164
+ --language_in ECMASCRIPT5_STRICT \
165
+ --externs lib/externs/json.js \
166
+ --js #{ input_path } \
167
+ --js_output_file #{ output_path } )
168
+
169
+ FileUtils . cp output_path , input_path
170
+ end
171
+
172
+
98
173
desc 'Minify JavaScript'
99
- task :minify => [ :init , :concat , :concat_scenario ] do
100
- [ 'angular.js' ,
101
- 'angular-cookies.js' ,
174
+ task :minify => [ :init , :concat , :concat_scenario , :minify_angular2 ] do
175
+ [ 'angular-cookies.js' ,
102
176
'angular-loader.js' ,
103
177
'angular-resource.js' ,
104
178
'angular-sanitize.js' ,
0 commit comments