uglifyjs

Why is it recommended to use concat then uglify when the latter can do both?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 09:45:16
问题 I keep seeing the recommendation for making JS files ready for production to be concat then uglify. For example here, in on of Yeoman's grunt tasks. By default the flow is: concat -> uglifyjs. Considering UglifyJS can do both concatenation and minification, why would you ever need both at the same time? Thanks. 回答1: Running a basic test to see if there is a performance difference between executing concat and then uglify vs. just uglify . package.json { "name": "grunt-concat-vs-uglify",

Angularjs minification using grunt uglify resulting in js error

点点圈 提交于 2019-11-27 05:03:48
In angularjs we pass parameters as dependency injection. For example, function checkInCtrl ($scope, $rootScope, $location, $http){ ….. …. } So when it gets minified, it becomes like, function checkInCtrl(a,b,c,d){ } Now a,b,c,d won’t be interpreted as $scope, $rootScope, $location, $http respectively by angular and whole code fails to work. For this angularjs has provided one solution, which is checkInCtrl.$inject = ['$scope', '$rootScope', $location', '$http']; we can inject different dependencies by using above syntax. This worked well till I didn’t use some custom angular service as

How to ignore files grunt uglify

断了今生、忘了曾经 提交于 2019-11-27 04:16:05
问题 Background I've just started using grunt as of about 30mins ago. So bear with me. But I have a rather simple script going that will look at my js and then compress it all into one file for me. Code "use strict"; module.exports = function (grunt) { // load all grunt tasks require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: { options: { beautify: true, report: 'gzip' }, build: { src: ['docroot/js/*.js',

remove console.logs with Webpack & Uglify

百般思念 提交于 2019-11-27 03:34:09
I am trying to remove console.logs with Webpack's Uglify plugin but it seems that Uglify plugin that comes bundled with Webpack doesn't have that option, its not mentioned in documentation. I am initializing uglify from webpack like this: new webpack.optimize.UglifyJsPlugin() My understanding is that I can use standalone Uglify lib to get all the options, but I don't know which one? The problem is that drop_console isn't working. Mayank Shukla With UglifyJsPlugin we can handle comments, warnings, console logs but it will not be a good idea to remove all these in development mode. First check

“Unknown provider: aProvider <- a” How do I find the original provider?

两盒软妹~` 提交于 2019-11-26 23:49:53
问题 When I'm loading the minified (through UglifyJS) version of my AngularJS application, I get the following error in the console: Unknown provider: aProvider <- a Now, I realize that this is due to variable name mangling. The unmangled version works just fine. However, I do want to make use of variable name mangling, as it drastically reduces the size of our JS output file. For that reason, we're using ngmin in our build process, but it doesn't seem to resolve this issue, even though it served

Angular.module minification bug

Deadly 提交于 2019-11-26 21:37:29
Having the darnedest time trying to figure out why minification is not working. I have injected via an array object my providers prior the function per numerous suggestions across the web and yet still "Unknown provider: aProvider <- a" Regular: var app = angular.module('bpwApp', ['ui.bootstrap', 'ui', 'myTabs']) .config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){ $routeProvider. when('/', {templateUrl: 'partials/home.jade', controller: HomeCtrl}); $locationProvider.html5Mode(true); }]) Minified: var app = angular.module('bpwApp', ['ui.bootstrap', 'ui',

Does it make sense to minify code used in NodeJS?

Deadly 提交于 2019-11-26 18:05:44
问题 I was wondering, since Clojure Compiler and UglifyJS not only optimize code for size but also for performance (although I think size is the main priority), would my node.js app run faster if it was minified ? I know it may depend from app, but I'm asking this in general. 回答1: In node, the main processing cost is I/O operations, not the actual JavaScript itself. So for example: fs.readFile(myFile, function (err, data) { processTheFile(data); }); Here, the gap between calling readFile and the

Excluding files/directories from Gulp task

不问归期 提交于 2019-11-26 12:45:46
I have a gulp rjs task that concatenates and uglifies all my custom .JS files (any non vendor libraries). What i am trying to do, is exclude some files/directories from this task (controllers and directives). Heres my tree: - application - resources - js main.js - vendor - jquery - modernzr - angular - controllers - controller1 - controller2 - controller3 - directives - directives1 - directives2 - directives3 - widgets - widget1 - widget2 - widget3 - widget4 - modules - modules1 - modules2 - modules3 - modules4 Here my gulp.js dir = { app: 'application', dest: 'dest', }; config = { src: { js:

Angularjs minification using grunt uglify resulting in js error

ⅰ亾dé卋堺 提交于 2019-11-26 11:27:07
问题 In angularjs we pass parameters as dependency injection. For example, function checkInCtrl ($scope, $rootScope, $location, $http){ ….. …. } So when it gets minified, it becomes like, function checkInCtrl(a,b,c,d){ } Now a,b,c,d won’t be interpreted as $scope, $rootScope, $location, $http respectively by angular and whole code fails to work. For this angularjs has provided one solution, which is checkInCtrl.$inject = [\'$scope\', \'$rootScope\', $location\', \'$http\']; we can inject different

Angular.module minification bug

穿精又带淫゛_ 提交于 2019-11-26 07:59:19
问题 Having the darnedest time trying to figure out why minification is not working. I have injected via an array object my providers prior the function per numerous suggestions across the web and yet still \"Unknown provider: aProvider <- a\" Regular: var app = angular.module(\'bpwApp\', [\'ui.bootstrap\', \'ui\', \'myTabs\']) .config([\'$routeProvider\', \'$locationProvider\', function($routeProvider, $locationProvider){ $routeProvider. when(\'/\', {templateUrl: \'partials/home.jade\',