Tips for sending data to uglify-js-harmony with gulp

I'm looking to minimize some JavaScript code that includes classes, but unfortunately, the current version of gulp-uglify doesn't support this feature as discussed in this thread.

I followed the advice given previously and installed

npm install uglify-js-harmony --save-dev
, but as a beginner in front-end development, I'm unsure how to pass my source through it like I could with gulp-uglify.

Here's what I have so far:

var uglify = require('uglify-js-harmony');

// ...

gulp.task('scripts', function(){
    return gulp.src(bower().concat(jsFiles))            
        .pipe(plumber())
        .pipe(concat('main.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest(dest + 'js'))
        .pipe(reload({stream:true}))
});

However, I keep getting an error message saying

[17:42:40] TypeError: uglify is not a function
, and I'm stuck on how to proceed. Any guidance would be appreciated. Thank you.

Answer №1

To simplify the process, consider using standard gulp-babel with gulp-uglify. .

$ npm install --save-dev gulp-uglify gulp-babel babel-preset-es2015

Next . . .

var uglify = require('gulp-uglify'),
    babel  = require('gulp-babel');


// ...

gulp.task('scripts', function(){
    return gulp.src(//... src stuff
        .pipe(babel({ presets: ['es2015']}))
        .pipe(uglify()))
        //... other stuff
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Firestore is failing to accept incoming data when the setDoc method is employed

I am encountering an issue with my app's connectivity to the Firestore database when attempting to utilize setDoc. The database is successfully operational for next-auth, creating records as intended. However, the problem arises when trying to enable ...

Combine two objects in javascript while disregarding any values that are undefined

Looking to combine two objects without overwriting defined values with undefined ones. X = { type: 'apple', quantity: undefined, price: '0.99' } Y = { type: 'orange', quantity: '10', price: undefined } Currently usi ...

Combining multiple 'Eithers' and 'Promises' in fp-ts: A guide to piping and chaining operations

Recently, I began working with fp-ts and wanted to create a method with functional-like behavior that would: Parse a bearer token Verify the validity of the user using the parsed token import { Request } from 'express'; import { either } from & ...

Executing PHP script within a Node.js socket server program

I have a JavaScript file running a normal TCP socket using node.js. Before sending a response back to the client, I need to validate the data using some PHP (MySQL) code. Can someone guide me on executing this PHP code inside the JavaScript file? Most of t ...

AngularJS routing creates a conflict with Express routing

Having an issue with routing in Express, specifically when using code like this: app.get("/profile/:param", function (req, res) It seems to be conflicting with the path routing in AngularJS. For example, when a view in Angular with a URL like /profile/so ...

Navigating from the Login Page to the Dashboard in Vue.js following successful token validation

I am facing an issue with the code that is supposed to redirect the User to the dashboard page if they have a token. Despite generating a JWT token from my Spring Boot backend and sending it to Vue for processing, the redirection is not working as expect ...

Oops! Before proceeding, make sure to call TestBed.initTestEnvironment() first

Currently, I am experimenting with testing a service in Angular. Below is the code snippet I am working on: describe('AddressService', () => { let service: AddressService; let injector: TestBed; let httpTestingController: HttpTesting ...

AngularJS allows for emitting the value from a search button based on the current state of a checkbox

Within my application, there is a Search Button that interacts with an internal API using a GET Request. This API retrieves Data that is sometimes protected. To simulate the Back-End behavior, there is a checkbox that is initially set to true. If the chec ...

Is it possible for the client to prevent the blocking of the Cross-Origin Resource Sharing (CORS) error?

I am encountering an issue with my web app that involves CORS operations when making $.getJSON AJAX calls. Typically, this functions properly on most client browsers due to the server having CORS enabled. However, I recently discovered that when using IE 1 ...

The SvelteKit server successfully loaded data, displaying it on the sources/index page in the Chrome

I am currently in the process of developing a basic web application that utilizes self-hosted Pocketbase on the backend and SvelteKit as a meta framework. Recently, I discovered that the data loaded by my server is visible in the browser's sources/in ...

Looking to retrieve the text content of an element using jQuery?

My goal is to use jQuery mobile to transfer a user to a linked page when they click on an <li> element, and then display an alert with the text of the list element they clicked. However, my current implementation only shows an empty alert box. < ...

How to access a specific element in an array hash with AngularJS using name or

Here is an example of an angular array used in a select tag: var names= [{name: 'Superman', val: '1'}, {name: 'Batman', val: '2'}]; $scope.names =names; $scope.FormData = {}; $scope.FormData.name = $scope.names[1]; ...

Validating Password Consistency using Javascript

I'm having trouble with validating the password fields and ensuring they match, even when both input boxes contain the same password. JavaScript var validator = $("#signupform").validate({ rules: { password: { required: true, minle ...

Disable Vue click event based on a condition

One issue I encountered was that even though I successfully disabled the document body scroll when my mobile nav was open, the overflow hidden feature was not being removed when a user clicked a link to another route or page. To address this, I implement ...

What is the best way to send a file to a JavaScript function within Django?

I am in the process of integrating the PhylD3 library into a Django Template. The CSS and JS files have been integrated into the Django static directory. However, I am unsure about the most efficient way to load the XML file in the template. Template - ...

How to Extract a Link from JSON Data in React Native

My JSON data is formatted like this: orderData:"<p>Key VVV: 6326233</p> <p>Download link <a title=\"Movie\" href=\"https://play.google.com/store/movies/details/The_Angry_Birds_Movie_2?id=O_RbjOHHpIs&hl=en\" t ...

Exploring the world of shapes and angles in three.js

I'm attempting to recreate a scene similar to this one, where the shapes have an outline: Unfortunately, neither of these two options are working: const material = new THREE.MeshNormalMaterial(); const material = new THREE.MeshBasicMaterial({ color: ...

Illustrate an element positioned beneath a child element within a different element

I am in the process of designing an overlay on a Google Map that resembles a real map placed on a table, using 2 pixel lines as creases above the map. This design does not significantly impact interactions with the map; only 6 out of 500 vertical lines are ...

Utilizing jQuery time intervals within a jQuery click event: A step-by-step guide

For my dropdown menu project, I am facing an issue where the menu bar is not reappearing after collapsing the dropdown. It seems that the jQuery function responsible for toggling classes within a time interval is not executing properly. Specifically, the " ...

Passing a MySQL connection to scripts in Express

After setting up the mysql connection with all the required parameters in app.js, is there a way to make it accessible to other scripts in routes/ without having to redeclare or require the mysql parameters again, simply by using client.query(..)? ...