A general-purpose JavaScript parser/compressor/beautifier toolkit developed on Node.js
Questions tagged [uglifyjs2]
112 questions
91
votes
7 answers
UglifyJS throws unexpected token: keyword (const) with node_modules
A small project I started make use a node module (installed via npm) that declares const variables. Running and testing this project is well, but browserify fails when UglifyJS is executed.
Unexpected token: keyword (const)
Here is a generic Gulp…
Yanick Rochon
- 45,203
- 21
- 112
- 182
46
votes
8 answers
How to minify multiple Javascript files in a folder with UglifyJS?
Hello I'm using uglifyJs to minify my javascript files, it's working well with one file at a time, what I'm loking for is to minify all the javascript files present in a folder called JS into a folder called JSM, to be clear I have 2 files inside my…
OussamaLord
- 997
- 4
- 25
- 39
41
votes
5 answers
Can uglify-js remove the console.log statements?
I'm using uglify-js to minify the source code. I want to remove the console.log statements of the original source code. Is it possible? Or is there any other compressor tool supports this?
I use the code as below in Node.js.
var uglify =…
Jeffrey
- 4,146
- 8
- 34
- 50
27
votes
2 answers
How to exclude certain requireJS files from uglifying/optimizing
I have a working requirejs project that is using grunt for building and deployment. If using no optimization at all, the build is working without problems and I get one big js file to deploy it on production.
The problem I have is, that I have some…
Marco Rinck
- 712
- 2
- 6
- 17
15
votes
4 answers
Using UglifyJs on the whole Node project?
I need to obfuscate my source code as best as possible so I decided to use uglifyjs2.. Now I have the project structure that has nested directories, how can I run it through uglifyjs2 to do the whole project instead of giving it all the input…
Tolga E
- 10,188
- 15
- 44
- 57
13
votes
5 answers
Failed to minify the code from this file
I am authoring a JavaScript library that I want to put on npm. I am currently using that library in another project and I have added it as a dependency using its GitHub repository:
"dependencies": {
// ... others
"react-web-component":…
Lukas
- 7,340
- 10
- 51
- 94
12
votes
2 answers
How to parse and iterate prototype methods with Uglify.js?
I 'd like to parse some JavasScript code to list all methods for a given "class" using uglify js 2. In my case the TreeWalker returns a node with name : null and there is no information that allow conclusions to parent.
Does anyone know a different…
Stephan Ahlf
- 2,839
- 3
- 31
- 65
11
votes
2 answers
Tell UglifyJS to skip a particular area of code
Is there a way to tell UglifyJS to skip a particular section of code, perhaps using comments like this:
// uglifyjs:skipStart
filter = function(item){ /* some crazy filter logic that will repeat 500,000 times */ }
// uglifyjs:skipEnd
My use case…
SimplGy
- 18,875
- 14
- 95
- 138
9
votes
2 answers
Lodash not TreeShaking with Webpack with Webpack 4?
I want to tree shake lodash as well as my unused multiply function from the generated bundle from webpack
I have 2 main files app.js & math.js
It contains the following code -
app.js
import map from "lodash/map";
import { sum } from…
deadcoder0904
- 3,758
- 1
- 27
- 91
9
votes
1 answer
Batch File Exits After Running One Node Application Script
I need to run several UglifyJS2 scripts with Node. I've added the command I want to run to a bat file and it runs OK.
When I add a second command, like "cd ..", the command isn't executed! Very confusing.
cd go somewhere
uglifyjs ..\somescript -o…
Greg
- 2,810
- 3
- 22
- 33
9
votes
3 answers
Uglify with SourceMaps while using grunt usemin and rev
I want to log javascript errors to server but the stacktrace is not useful with minified JS code. So I was thinking of using either Getsentry or Rollbar which shows proper stack trace with the help of sourcemaps. But I'm struggling to create…
IsmailS
- 10,338
- 18
- 73
- 128
8
votes
1 answer
UglifyJS property mangling
According to the docs, UglifyJS can mangle all property names except those on a provided reserved list. Is it possible to do it the other way, so only properties on provided list will be mangled?
If so, what options do I need to pass to…
Sebastian Nowak
- 5,359
- 7
- 58
- 105
8
votes
5 answers
Mangle nested classes and variables with UglifyJS
I use UglifyJS to minify a concatenated set of files, which works fine but not good enough. The built lib uses namespaces, so classes, functions and constants are stored in a root namespace variable:
(function() {
var root = { api:{}, core:{},…
whadar
- 3,209
- 4
- 17
- 19
7
votes
2 answers
Webpack's removes classnames when minifying/uglifying ES6 code with inheritance
Webpack's removes classnames when minifying/uglifying ES6 code with inheritance:
There's MVCE code which we try to minify/uglify:
Class Child:
const ParentClass = require('parent');
class Child extends ParentClass{
constructor(){
…
Anatoly
- 4,553
- 6
- 42
- 110
7
votes
1 answer
UglifyJS webpack plugin throws: Unexpected token: name (features)
I used to have problems with UglifyJS for Webpack and ES6 modules:
ERROR in static/js/vendor.6ccd9e38979a78765c7a.js from UglifyJs
Unexpected token: name (features)
…
alex
- 5,551
- 8
- 34
- 67