uglifyjs

how to minify js files in order via grunt-contrib-uglify?

元气小坏坏 提交于 2019-12-02 18:47:56
I have a directory like below: /folder/b.js /folder/jQuery.js /folder/a.js /folder/sub/c.js I want to minify all these js files in one js file in order : jQuery.js -> a.js -> b.js -> c.js Q: 1.How can I do it via grunt-contrib-uglify?(In fact, there are lots of files, it is impractical to specify all source filepaths individually) 2.btw, How can I get unminified files when debug and get minified single file when release and no need to change script tag in html(and how to write the script tag)? Good questions! 1) Uglify will reorder the functions in the destination file so that function

What's the difference between concat and uglify and minify?

二次信任 提交于 2019-12-02 17:50:52
What's the difference between concat, uglify, and minify tasks in grunt? I set up an uglify task for all of my site's javascript tasks, and it seemed to both minify and concatenate them. Grunt's site has a great description for how to configure each task, but it doesn't seem to explain what each task actually does. diclophis Concatenation is just appending all of the static files into one large file . Minification is just removing unnecesary whitespace and redundant / optional tokens like curlys and semicolons, and can be reversed by using a linter. Uglification is the act of transforming the

Minify multiple files with UglifyJS

纵然是瞬间 提交于 2019-12-02 15:09:09
Is it possible to compress multiple files with UglifyJS? Something like... uglifyjs -o app.build.js appfile1.js appfile2.js ... Also, I am running Uglify via NodeJS in Windows Command Prompt Actually what you want to do (trick it into thinking its just 1 file) is just cat it Linux cat file1.js file2.js file3.js file4.js | uglifyjs -o files.min.js Windows (untested) type file1.js file2.js > uglifyjs -o files.min.js OR type file1.js file2.js > merged.files.js uglifyjs -o merged.files.js For future readers of this question, w/ UglifyJS2, this is trivial now... uglifyjs file1.js file2.js -o foo

How to uglify output with Browserify in Gulp?

孤街浪徒 提交于 2019-12-02 13:52:27
I tried to uglify output of Browserify in Gulp, but it doesn't work. gulpfile.js var browserify = require('browserify'); var gulp = require('gulp'); var uglify = require('gulp-uglify'); var source = require('vinyl-source-stream'); gulp.task('browserify', function() { return browserify('./source/scripts/app.js') .bundle() .pipe(source('bundle.js')) .pipe(uglify()) // ??? .pipe(gulp.dest('./build/scripts')); }); As I understand I cannot make it in steps as below. Do I need to make in one pipe to preserve the sequence? gulp.task('browserify', function() { return browserify('./source/scripts/app

Uglify one JS file using requirejs optimizer

旧城冷巷雨未停 提交于 2019-12-02 06:26:02
问题 I'd like to know if there is a way to uglify only one file in command line using r.js (RequireJS Optimizer) which is already installed in my computer. Like we can minify a css file using node r.js cssIn="" out="" ... I'm actually working from a computer without internet connection, I'm not able to install something else on it (especially using npm) Maybe is there a possibility to download an uglifyjs package from another computer including all dependencies ready to be installed on mine? I

What is wrong with this code that combines multiple js files to one?

流过昼夜 提交于 2019-12-02 02:53:42
问题 I have this node.js code that tries to minify and combine multiple js files to a single js file. var concat = require('gulp-concat'); var gulp = require('gulp'); gulp.task('scripts', function() { //gulp.src(['./lib/file3.js', './lib/file1.js', './lib/file2.js']) gulp.src(['./js/*.js']) .pipe(concat('all.js')) .pipe(uglify()) .pipe(gulp.dest('./dist/')) }); All my js files are located in js folder. My node.js file is above the js folder. I am expecting the single minified file to appear in

What is wrong with this code that combines multiple js files to one?

Deadly 提交于 2019-12-02 01:43:22
I have this node.js code that tries to minify and combine multiple js files to a single js file. var concat = require('gulp-concat'); var gulp = require('gulp'); gulp.task('scripts', function() { //gulp.src(['./lib/file3.js', './lib/file1.js', './lib/file2.js']) gulp.src(['./js/*.js']) .pipe(concat('all.js')) .pipe(uglify()) .pipe(gulp.dest('./dist/')) }); All my js files are located in js folder. My node.js file is above the js folder. I am expecting the single minified file to appear in dist folder. I see nothing and get no error message when I run the code. What could have gone wrong?

Uglify one JS file using requirejs optimizer

那年仲夏 提交于 2019-12-02 01:33:26
I'd like to know if there is a way to uglify only one file in command line using r.js (RequireJS Optimizer) which is already installed in my computer. Like we can minify a css file using node r.js cssIn="" out="" ... I'm actually working from a computer without internet connection, I'm not able to install something else on it (especially using npm) Maybe is there a possibility to download an uglifyjs package from another computer including all dependencies ready to be installed on mine? I didn't find something like that though... Thanks Copy uglify from another computer Since you mentioned

Prevent uglifyjs from renaming certain functions

馋奶兔 提交于 2019-12-02 00:53:48
问题 I have a function that has a constructor within it. It creates a new object and returns it: function car() { function Car() {} return new Car(); } As a result uglify renames Car to some letter and when this returns it looks like the object name is just some letter. In chrome for instance it will say the type of the object is "t". Is there a way to tell uglify to preserve some function's name? 回答1: You need to use the reserved-names parameter: --reserved-names “Car” 回答2: Even if you follow

SyntaxError: Unexpected token: punc ())

一世执手 提交于 2019-12-01 22:22:02
问题 I'm recieving: SyntaxError: Unexpected token: punc ()) from UglifyJS and it points to the first letter of global variable API_URL . I have it implemented in this way: export default reduxApi({ campaigns: { url: `${API_URL}/api/v1/whatever`, transformer (response) { if (!response) return {} return response.data } } }).use('fetch', adapterFetch(fetch)).use('options', { headers: getRequestHeaders() }) If I remove global variable under key url : export default reduxApi({ campaigns: { url: `/api