File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ or just made Pipeline more awesome.
5454 * Evan Myller <eMyller@7ws.co>
5555 * Fabian Büchler <fabian.buechler@gmail.com>
5656 * Feanil Patel <feanil@edx.org>
57+ * Felix Last <mail@felixlast.de>
5758 * Florent Messa <florent.messa@gmail.com>
5859 * Frankie Dintino <fdintino@theatlantic.com>
5960 * Hannes Ljungberg <hannes.ljungberg@gmail.com>
Original file line number Diff line number Diff line change @@ -173,6 +173,35 @@ Install the slimit library with your favorite Python package manager ::
173173 pip install slimit
174174
175175
176+ Terser compressor
177+ ===================
178+
179+ `Terser <https://github.com/terser/terser >`_ is a JavaScript parser and
180+ mangler/compressor toolkit for ES6+. It has been designed as a successor of
181+ ``uglify-es `` and ``uglify-js ``. The compressor works with ES5 and ES6 and
182+ regular ``.js `` file endings.
183+
184+ To use it add this to your ``PIPELINE['JS_COMPRESSOR'] `` ::
185+
186+ PIPELINE['JS_COMPRESSOR'] = 'pipeline.compressors.terser.TerserCompressor'
187+
188+
189+ ``TERSER_BINARY ``
190+ ----------------------------
191+
192+ Command line to execute for the terser program.
193+ You will most likely change this to the location of terser on your system.
194+
195+ Defaults to ``'/usr/bin/env terser' ``.
196+
197+ ``TERSER_ARGUMENTS ``
198+ -------------------------------
199+
200+ Additional arguments to use when terser is called.
201+
202+ Default to ``'--compress' ``
203+
204+
176205CSSTidy compressor
177206==================
178207
Original file line number Diff line number Diff line change 2020 "stylus" : " latest" ,
2121 "cssmin" : " latest" ,
2222 "google-closure-compiler" : " latest" ,
23+ "terser" : " latest" ,
2324 "uglify-js" : " latest" ,
2425 "yuglify" : " 1.0.x" ,
2526 "yuicompressor" : " latest"
Original file line number Diff line number Diff line change 1+ from __future__ import unicode_literals
2+
3+ from pipeline .conf import settings
4+ from pipeline .compressors import SubProcessCompressor
5+
6+
7+ class TerserCompressor (SubProcessCompressor ):
8+ def compress_js (self , js ):
9+ command = (settings .TERSER_BINARY , settings .TERSER_ARGUMENTS )
10+ if self .verbose :
11+ command += ' --verbose'
12+ return self .execute_command (command , js )
Original file line number Diff line number Diff line change 4848
4949 'UGLIFYJS_BINARY' : '/usr/bin/env uglifyjs' ,
5050 'UGLIFYJS_ARGUMENTS' : '' ,
51+
52+ 'TERSER_BINARY' : '/usr/bin/env terser' ,
53+ 'TERSER_ARGUMENTS' : '--compress' ,
5154
5255 'CSSMIN_BINARY' : '/usr/bin/env cssmin' ,
5356 'CSSMIN_ARGUMENTS' : '' ,
Original file line number Diff line number Diff line change 1+ ( function ( ) { window . concat = function ( ) { console . log ( arguments ) } , window . cat = function ( ) { console . log ( "hello world" ) } } ) . call ( this ) ;
Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ def node_exe_path(command):
170170 'LIVE_SCRIPT_ARGUMENTS' : ['--no-header' ],
171171 'YUGLIFY_BINARY' : node_exe_path ('yuglify' ),
172172 'UGLIFYJS_BINARY' : node_exe_path ('uglifyjs' ),
173+ 'TERSER_BINARY' : node_exe_path ('terser' ),
173174 'CSSMIN_BINARY' : node_exe_path ('cssmin' ),
174175 })
175176
Original file line number Diff line number Diff line change @@ -240,7 +240,12 @@ def test_csshtmljsminify(self):
240240 def test_uglifyjs (self ):
241241 self ._test_compressor ('pipeline.compressors.uglifyjs.UglifyJSCompressor' ,
242242 'js' , 'pipeline/compressors/uglifyjs.js' )
243-
243+
244+ @skipUnless (settings .HAS_NODE , "requires node" )
245+ def test_terser (self ):
246+ self ._test_compressor ('pipeline.compressors.terser.TerserCompressor' ,
247+ 'js' , 'pipeline/compressors/terser.js' )
248+
244249 @skipUnless (settings .HAS_NODE , "requires node" )
245250 def test_yuglify (self ):
246251 self ._test_compressor ('pipeline.compressors.yuglify.YuglifyCompressor' ,
You can’t perform that action at this time.
0 commit comments