简体   繁体   中英

How to work with browserify and closure/unlifyjs?

Browserify is awsome which can be used to generate a single js file from nodejs module files, which enable developer reuse many node js modules that can be used in broweser. While as web release, we need to use google closure or uglifyjs to condense or compress js files. Is there best pratice to work with browserify and closure/unlifyjs? should I browserify my js project in a single file first then compress the single file or in a vise verse manner?

Browserify it, then minify it. You can squeeze out a bit more sometimes by also using uglifyify, which minifies each module before incorporating it into the bundle.

If you care about sourcemaps, you should pass the original files to the minifier/compiler. Both uglify and Closure-compiler can take a large source set of files and produce a single output file.

If you combine all your source files together and pass that single file to your compressor/minifier, then your sourcemaps will refer to positions in the monolithic combined file and not their original location.

If you don't need sourcemaps, then there isn't a clear advantage to either approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM