uglifyjs

Aggregating and uglifying javascript in a git pre-commit hook

徘徊边缘 提交于 2020-01-02 07:38:56
问题 I'm using ready.js to aggregate JS files into an all.js file (without Google's Closure Compiler), and then using uglify-js to minify and obfuscate the code. I'd like to do all of this in a pre-commit hook. However, I think I'm doing something wrong. My .git/hooks/pre-commit file looks like this: #!/bin/sh readyjs ~/Sites/backbone/js/javascripts/ ~/Sites/backbone/js/ --nojslint -o "underscore.js, backbone.js" --nocompiler uglifyjs -nm -o ~/Sites/backbone/js/all.min.js ~/Sites/backbone/js/all

Why does uglify-js report 'WARN: Output exceeds 32000 characters'?

被刻印的时光 ゝ 提交于 2020-01-02 00:56:14
问题 build pipeline is: Typescript, browserify, browserify-css, uglify. runtime libraries: react, bootstrap. My application so far has very little functionality (that's why I'm asking if this is going to bite me later, even though it appears to work for now). Later on it will get bigger (react-router, redux, other js libraries like Auth0, maybe even some actual functionality.) I have an app.css that contains: @import url("node_modules/bootstrap/dist/css/bootstrap.css"); I then import that into my

Javascript minification why is false replaced with !1 and true with !0 [duplicate]

≡放荡痞女 提交于 2020-01-01 07:58:05
问题 This question already has an answer here : Is there any point of using “return !0” in javascript? (1 answer) Closed 3 years ago . I'm writing an app using Enyo2 which comes with a minification tool based on UglifyJS. I've noticed that: var t = false is replaced with var t=!1 The same way true is replaced with !0. I'm sure there is a good explanation for that, I just can't find it. Any idea? 回答1: There is one apparently. If you use 1 or 0 to translate true or false, it would be shorter but

Javascript minification why is false replaced with !1 and true with !0 [duplicate]

天大地大妈咪最大 提交于 2020-01-01 07:57:04
问题 This question already has an answer here : Is there any point of using “return !0” in javascript? (1 answer) Closed 3 years ago . I'm writing an app using Enyo2 which comes with a minification tool based on UglifyJS. I've noticed that: var t = false is replaced with var t=!1 The same way true is replaced with !0. I'm sure there is a good explanation for that, I just can't find it. Any idea? 回答1: There is one apparently. If you use 1 or 0 to translate true or false, it would be shorter but

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

流过昼夜 提交于 2019-12-31 08:35:21
问题 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. 回答1: 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

uglify js error unexpected token eof “undefined”

我的梦境 提交于 2019-12-30 17:56:21
问题 So I installed npm using npm install uglify-js I run a command which is: cat file1.js file2.js .. fileN.js | uglifyjs -o files.min.js and I get this error: WARN: ERROR: Unexpected token eof «undefined», expected punc «,» [-:630,15] /usr/local/lib/node_modules/uglify-js/lib/parse.js:199 throw new JS_Parse_Error(message, line, col, pos); ^ Error at new JS_Parse_Error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:185:18) at js_error (/usr/local/lib/node_modules/uglify-js/lib/parse.js:199

Why does this JavaScript work?

怎甘沉沦 提交于 2019-12-30 16:21:31
问题 I was looking at the output of some stuff from UglifyJS and happened across some code like the following: var a = 0; var b = function () { return function () { a++; }(), 'Hello, World' }(); After running that code a is 1 and b is the string Hello, World! . At first glance it appears that b will be undefined since it looks like the result of a function with no return value is being returned, but that is followed by a comma and a string literal. Why does this work? And why doesn't UglifyJS just

uglify js error. Unexpected token: eof (undefined)

半世苍凉 提交于 2019-12-25 07:35:09
问题 I keep getting a Unexpected token error and I can't seem to figure out why. I am using uglifyJS with the grunt-contrib-uglify task but am also getting the error using the command line. Using gulpfile c:\path\to\gulpfile.js [14:05:53] Starting 'build'... [14:05:53] Starting 'clean:build'... [14:05:53] Finished 'clean:build' after 30 ms [14:05:53] Starting 'sass:build'... [14:05:56] Finished 'sass:build' after 2.52 s [14:05:56] Starting 'images'... [14:06:03] gulp-imagemin: Minified 3 images

Cannot fix “Unexpected token name «i», expected punc «;»” from UglifyJs

为君一笑 提交于 2019-12-24 20:27:22
问题 I have created a react app with a custom next server server.js : const { createServer } = require('http'); const next = require('next'); const app = next({ dev: process.env.NODE_ENV !== 'production', conf: { webpack: config => { config.devtool = false; for (const r of config.module.rules) { if (r.loader === 'babel-loader') { r.options.sourceMaps = false; } } return config; } } }); const routes = require('./routes'); const handler = routes.getRequestHandler(app); app.prepare().then(() => {

uglify-js in nodeJS “Cannot find module”

可紊 提交于 2019-12-24 04:39:26
问题 Here i am creating application to compress a javascript file Steps i made, Installed nodeJS in my local machine checked node and npm is working Installed "uglify-js" by "npm install uglify-js -g" and installed When i try to run by "node server.js" in command prompt throwing error Error : Cannot find module 'uglify-js' Server.js var UglifyJS = require('uglify-js'); var fs = require('fs'); var result = UglifyJS.minify('site.js', { mangle: true, compress: { sequences: true, dead_code: true,