uglifyjs2

Lodash not TreeShaking with Webpack with Webpack 4?

一曲冷凌霜 提交于 2019-12-05 06:23:15
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 "./math"; console.log("💩"); console.log(`2 + 3 = ${sum(2, 3)}`); map([1, 2, 3], x => { console.log(x); }); math.js export const sum = (a, b) => a + b; export const multiply = (m, n) => m * n; webpack.config.js const path = require("path"); const webpack = require("webpack"); const UglifyJSPlugin = require("uglifyjs-webpack-plugin"); const Jarvis = require("webpack

UglifyJS webpack plugin throws: Unexpected token: name (features)

旧街凉风 提交于 2019-12-04 11:19:16
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) [./node_modules/pica/lib/mathlib.js:19,0][static/js/vendor.6ccd9e38979a78765c7a.js:39003,6] I read that the new beta version of the Webpack plugin supports ES6: https://github.com/webpack-contrib/uglifyjs-webpack-plugin new webpack.optimize.UglifyJsPlugin({ uglifyOptions: { ie8: false, ecma: 8, // I also tried 7 and 6 parse: {}, mangle: { properties: { // mangle property options } }, output: { comments: false, beautify: false },

Using UglifyJs on the whole Node project?

孤者浪人 提交于 2019-12-03 15:51:59
问题 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 files? I wouldn't mind if it minified the whole project into a single file or something 回答1: I've done something very similar to this in a project I worked on. You have two options: Leave the files in their directory structure. This is by far the easier

How to exclude certain requireJS files from uglifying/optimizing

六月ゝ 毕业季﹏ 提交于 2019-12-03 06:42:08
问题 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 external frameworks (like angularJS) where I already have a minimized/optimized version of it and don't want to optimize it again. Currently without optimization I include the minified version of this framework via a seperate path config in my

Using UglifyJs on the whole Node project?

丶灬走出姿态 提交于 2019-12-03 05:16:01
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 files? I wouldn't mind if it minified the whole project into a single file or something josh3736 I've done something very similar to this in a project I worked on. You have two options: Leave the files in their directory structure. This is by far the easier option, but provides a much lower level of obfuscation since someone interested enough in your code

UglifyJS throws unexpected token: keyword (const) with node_modules

喜你入骨 提交于 2019-11-30 05:35:21
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 file that I have successfully been using for a few other past projects without this issue (i.e. without that particular node module). gulpfile.js 'use strict'; const browserify = require('browserify'); const gulp = require('gulp'); const source = require('vinyl-source-stream'); const derequire = require('gulp-derequire'); const buffer = require(

Mangle nested classes and variables with uglifyjs

ε祈祈猫儿з 提交于 2019-11-30 04:56:33
问题 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:{}, names:{} }; /* util.js file */ root.names.SOME_LONG_NAMED_CONST='Angel'; /* Person.js file */ root.core.Person = function(name) { this.name = name }; /* API.js with the functions we want to expose */ root.api.perform = function(param_for_api) { /* do

Source maps with grunt

杀马特。学长 韩版系。学妹 提交于 2019-11-29 02:21:48
Do you know of a workflow that includes source maps for an app compiled with grunt? I am well aware of plugins like uglifyjs that allow you to simply generate a source map. But I'm looking for incorporating this into a more complex workflow, rather than just making a one-off source map. I've noticed that the most popular Yeoman generators (that I know of) are missing source maps in their workflows. Is this just because of a lack of support in the major plugins for source maps? Or is it instead that source maps aren't necessary in work flows, and I just can't think of a clever enough

How to minify multiple Javascript files in a folder with UglifyJS?

对着背影说爱祢 提交于 2019-11-28 03:15:42
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 JS folder called test1.js and test2.js and I want to run uglify against that folder and generate test1.min.js and test2.min.js inside the JSM folder, so is there a way to do this? a command like : uglifyjs -c -m JS/*.js JSM/*.min.js Or any idea that can help me. Thanks. I know it might seem like a huge step but I would really recommend using grunt

Can uglify-js remove the console.log statements?

随声附和 提交于 2019-11-27 18:29:16
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 = require('uglify-js'); var originalSourceCode = 'var name = function(){var str = "test"; return str}; console.log("log data");'; var minifiedCode = uglify.minify(originalSourceCode, { fromString : true, mangle: {}, warnings: true }); console.log(minifiedCode); The output is: $node m.js { code: 'var name=function(){var a="test";return a};console.log("log data");