uglifyjs

Javascript regex to match a pattern but NOT match a regex literal (r.js optimizer and uglify issue)?

一笑奈何 提交于 2019-12-12 02:26:43
问题 I've got a Backbone application, organized into modules using Require.js. One of these modules contains a Handlebars helper, which has a method I use to pull a legal header off of all our HTML templates for each View. The header is contained in an HTML comment, so I use the following regex to strip it off: /<!--[\s\S]*?-->/g Now, when I optimize (concatenate/compile/minify) the application using r.js, I'm doing the same removal of HTML comments using the onBuildWrite() method of r.js:

How to import UglifyJS from Scala.js?

陌路散爱 提交于 2019-12-12 01:39:20
问题 I can use jQuery from Scala.js quite well: jsDependencies += "org.webjars" % "jquery" % "2.2.1" / "jquery.js" minified "jquery.min.js" Now I would like to use UglifyJS and its webjar structure seems a bit different. There seems to be no minified js file, and even the main file which probably contains the complete library looks different, it has no .js extension and it starts with following lines: #! /usr/bin/env node // -*- js -*- "use strict"; var UglifyJS = require("../tools/node"); Can

Webpack UglifyJS fall in error for production build because of MQTT.js existance

拜拜、爱过 提交于 2019-12-11 07:33:25
问题 I have a react web app with server side rendering and I separate webpack configuration for development and production environment. For each environment, I set two side configurations, first client and second server . these configs are so complete and work awesome, but I need to have mqtt.js in this project, this library has #!/usr/bin/env node in first of its code sheet and using this library cause to running dev and build script fall in this error: ERROR in ./node_modules/mqtt/mqtt.js Module

Browserify uglify via node script or command line?

一世执手 提交于 2019-12-11 03:17:49
问题 It seems in many places the professionals are building their projects using a node.js script that involves either gulp or grunt. What I can't figure out though, is why the script method is preferrable? When switching from the command line version to the script version, you add other packages in: i.e. gulp-uglify, vinyl-source-stream and vinyl-buffer. Wouldn't it be safer long-term-wise to use a method with the least amount of dependencies? Take for example the following command line method

AngularJS: minifications breaks my directive

拈花ヽ惹草 提交于 2019-12-10 20:26:22
问题 I use a directive to ask user for action confirmations in modals. It works like a charm during development, but, after minification, it's broken. This is the dreadful " $injector: unpr " error I get: Error: [$injector:unpr] Unknown provider: aProvider <- a ... I presume the problem is that $scope and $modalInstance are renamed, and should not be, but I don't know how to avoid this... This is the directive code: 'use strict'; app.directive('reallyClick', ['$modal', function($modal) { var

calling node and uglifyjs from Php context

戏子无情 提交于 2019-12-10 19:01:19
问题 I'm trying out the JS minifier library UglifyJS2. I installed node.js on my mac using homebrew, and then uglifyjs through npm. It all works fine in the shell, node is found in the path and I manually added "uglifyjs" to the path so can find it just by typing "uglifyjs" (it is installed here: /usr/local/share/npm/lib/node_modules/uglify-js/bin/uglifyjs). This is done in ".bash_profile". So, I can run everything fine in the terminal. I would now like to run it in a web context, in a Php page,

gulp-uglify won't preserve files order

不羁岁月 提交于 2019-12-10 10:56:46
问题 When I use gulp-uglify to minify the Javascript files the order gets messed up. Lets say I have this task working as expected: var gulp = require('gulp'); var rename = require('gulp-rename'); var gp_concat = require('gulp-concat'); gulp.task('js', function() { gulp.src([ './public/bower_components/jquery/dist/jquery.min.js', './public/js/functions.js', ]) .pipe(gp_concat('combined.js')) .pipe(gulp.dest(path.js + '/dist')) }); Adding the uglify line to it changes the order of the jquery and

Typescript: get class name in its own property at compile time

微笑、不失礼 提交于 2019-12-10 09:58:26
问题 For example if we have a class like this: class MyClass { className: string; } Is it possible to get 'MyClass' assigned to className property at compile time? EDIT: already tried this.constructor.name. However, latter doesnt help with minified code. Hence checking if there is a way to capture class name when typescript code is compiled to JS. I'm using angular-cli. 回答1: /additional answer Since you need the actual name of the original class even after uglifying, you will need to look into

Lodash not TreeShaking with Webpack with Webpack 4?

别等时光非礼了梦想. 提交于 2019-12-10 04:28:55
问题 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 V4: Remove console.logs with Webpack & Uglify

烈酒焚心 提交于 2019-12-09 17:44:43
问题 This answer worked like a charm previously: https://stackoverflow.com/a/41041580/3894981 However, since Webpack v4 it doesn't work anymore. Since then it throws: Error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead. What is necessary here in order to make it work in Webpack v4? I've tried using the following without luck: const uglifyJsPlugin = require('uglifyjs-webpack-plugin'); if (process.argv.indexOf('-p') !== -1) { // compress and