uglifyjs

How to configure grunt-contrib-uglify to minify files while retaining directory structure

China☆狼群 提交于 2019-12-06 01:07:06
问题 In case I have multiple subdirectories under 'js' directory in the example Gruntfile posted below, and want to retain the subdirectories under a different destination directory, how do I do it? For e.g. module.exports = function (grunt) { grunt.initConfig({ // define source files and their destinations uglify: { files: { src: 'js/**/*.js', // source files mask dest: 'minJs/', // destination folder expand: true, // allow dynamic building flatten: true, // remove all unnecessary nesting } } });

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 },

webpack 4 disable uglifyjs-webpack-plugin

对着背影说爱祢 提交于 2019-12-04 10:31:01
问题 I have had this problem for the last 2 days. So I decided to completely disable uglifyjs-webpack-plugin from webpack build process. I was not able to find anything on webpack 4. 回答1: module.exports = { optimization:{ minimize: false, // <---- disables uglify. // minimizer: [new UglifyJsPlugin()] if you want to customize it. } } 来源: https://stackoverflow.com/questions/51263506/webpack-4-disable-uglifyjs-webpack-plugin

Rails asset pipeline and javascript files - maintaining line breaks to aid debugging

放肆的年华 提交于 2019-12-04 10:22:51
I recently migrated from Jammit to the Rails Asset Pipeline . Other than a few teething issues, everything has been working well. However, I recently started getting some script errors in production, and realised that it's near on impossible for me to debug them. I had previously configured Jammit to retain linebreaks, but otherwise remove all white space in the javascript files. This was to ensure that should I see a runtime error, I would be able to locate the offending line and hopefully figure out what the problem is. With the Rails Asset Pipeline, and the default :uglifier compressor, it

Gulp ngmin + uglify not working properly

三世轮回 提交于 2019-12-04 08:19:31
问题 I have the following gulp task: gulp.task('scripts', function() { return gulp.src(['app/js/app.js', 'app/config/config.js', 'app/js/controllers.js', 'app/js/directives.js' , 'app/js/filters.js', 'app/js/footer.js', 'app/js/guideTour.js', 'app/js/mobileBanner.js', 'app/js/services.js', 'app/js/youtube.js', 'app/js/dataSync.js', 'app/js/addthis.js']) //.pipe(jshint('.jshintrc')) .pipe(jshint.reporter('default')) .pipe(concat('main.js')) .pipe(ngmin()) .pipe(gulp.dest('app/dist/js')) .pipe

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

∥☆過路亽.° 提交于 2019-12-03 22:26:43
This question already has an answer here : Closed 3 years ago . Is there any point of using “return !0” in javascript? (1 answer) 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? There is one apparently. If you use 1 or 0 to translate true or false, it would be shorter but seen as integers. If you add ! in front and reverse them, it will be coalesced into booleans and still be short

Uglify-js doesn't mangle variable names

帅比萌擦擦* 提交于 2019-12-03 17:58:02
问题 Trying to prepare good build environment for my js library. According to reviews on the web UglifyJS seems to be one of the best compressing modules out there, working under NodeJS. So here is best recommended way of minifying the code: var jsp = require("uglify-js").parser; var pro = require("uglify-js").uglify; var orig_code = "... JS code here"; var ast = jsp.parse(orig_code); // parse code and get the initial AST ast = pro.ast_mangle(ast); // get a new AST with mangled names ast = pro.ast

How to define individual flows in useminPrepare for each block in html file?

末鹿安然 提交于 2019-12-03 17:31:30
问题 We have 2 blocks defined in our index.html - one for 3rd party libs and one for our application files. Since 3rd party libs are already minified, we just want to concatenate them, but not uglify. How can I do this with useminPrepare ? <!-- build:js js/lib.js --> <script src="lib/angular/angular.min.js"></script> <script src="lib/angular-cookies/angular-cookies.min.js"></script> <script src="lib/angular-route/angular-route.min.js"></script> <!-- endbuild --> <!-- build:js js/app.js --> <script

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