Merge all the files into one without applying any compression

I am new to using GruntJS and I am currently adding Uglify to my project.

I have configured it to compile all of my JS into one file, but during development, I would like it to not compress the code.

After looking at the documentation, I see there is a boolean option for this. However, even with the following setup:


...
options: {
  compress: false
}
...

The code still gets compressed. What am I missing?

Answer №1

I rely on grunt-contrib-concat for merging files and then use grunt-contrib-uglify to compress the resulting merged file.

Here is an example of my concatenation task:

concat : {
    options : {
        stripBanner : true
},
    header : {
        src : [header1.js, header2.js, header3.js],
        dest : ['/path/to/js/tmpfolder/', '<%=pkg.name %>.header.js'].join('/')
    },
    application : {
       src : [app1.js, app2.js, app3.js],
       dest : ['/path/to/js/tmpfolder/', '<%=pkg.name %>.app.js'].join('/')
    }
}

Similarly, my minification task looks like this:

uglify : {
    all : {
        options : {
            banner : "/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today(\"yyyy-mm-dd\") %> \n <%= pkg.author %> */",
            dead_code : true
    },
        files : uglifyFiles
     }
}

To make it work, I also have to define the `uglifyFiles` variable as follows:

uglifyFiles = {};
uglifyFiles['/path/to/js/tmpfolder/<%=pkg.name %>.header.min.js'] =  '/path/to/js/tmpfolder/<%=pkg.name %>.header.js';
uglifyFiles['/path/to/js/tmpfolder/<%=pkg.name %>.app.min.js'] = '/path/to/js/tmpfolder/<%=pkg.name %>.app.js';

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

Skipping a JSON field in HTML/JavaScript when it is blank: A guide for developers

To develop an interactive program based on JSON input, I aim to display headers, subheaders, and choices derived from the JSON data. Some input fields may remain unfilled. For instance: Header Subheader Choice 1 Choice 2 Subheader2 Choice ...

Issue with Bootstrap 4 tab.js not updating active states

I am having trouble with 2 out of the 4 tab.js examples in both CodePen and a local HTML file. The "nav" example is causing the items in the dropdown to stay active and inaccessible after clicking. The same issue occurs with all the items in the vertical t ...

Extending the href value using jQuery at the end

Can someone help me with this link: <a id="Link" href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2745425453424b4b524940674e0a4355464e4909494253">[email protected]</a>?subject=I-Drain Bestellung& ...

How come AngularJS $onChanges isn't able to detect the modification in the array?

What is the reason behind Angular's failure to detect changes in an array, but successfully does so after changing it to null first? In my AngularJS component, I utilize a two-way data binding to pass an array. The parent component contains a button ...

The findIndex() method will consistently return a value of -1 when used on an array

I am struggling to find a solution for the following problem. Instead of returning 1, the index is always -1 in this case. Can anyone assist me with this? let allRules = [{ruleName: "a"}, {ruleName: "b"}, {ruleName: "c"}] let name = "b" let index = allR ...

The identifier 'name' is not found in the specified data type

How can I resolve the error 'Property 'name' does not exist on type' in TypeScript? Here is the code block : **Environment.prod.ts** export const environment = { production: true, name:"(Production)", apiUrl: 'https://tes ...

When I try to run npm start with ReactJS, my localhost 3000 shows a blank page

After starting work on a new React app, I decided to name it the Covid-19 tracker. When I initially ran npm start, everything looked great with the h1 heading displaying properly. However, things took a turn after I installed some dependencies: npm install ...

Tips for customizing the appearance of a timer using javascript and css

Check out this fiddle linked here: jsfiddle First, have a look at the initial HTML code below. For the JavaScript part, refer to the fiddle: <div id="test_time_left">Time Left :<b><span id="time_value" style="padding-left:5px;"></spa ...

Attempting to dynamically link my "ng-true-value" in AngularJS

Working with values retrieved from a database, my goal is to include a checkbox, load the description, and provide 2 text boxes – one editable and the other read-only. Both text boxes initially display values from the database. When the checkbox is chec ...

What could be the reason behind the unexpected behavior of my Bootstrap 3 carousel?

I'm attempting to replicate this visual effect in my own carousel, featuring semi-transparent images on the left and right sides. However, I'm encountering a negative result with my project when transitioning between slides at : here. This is th ...

Handling the same form button repeatedly in a loop using jQuery

I have successfully set up jquery to accept form data and send it to flask, but I am facing two issues: It only accepts the first form, which has the same IDs repeated for each element. I want all forms to be able to submit. When a submission occurs, it ...

Retrieve the callback arguments using sinon.spy within a JavaScript promise

During my test with mocha and sinon, I encountered an issue where I couldn't retrieve a callback value from inside a promise scope of an HTTP-request due to the asynchronous nature of promises. It seems that by the time sinon.spy checks on the callbac ...

During testing, the Vuetify expansion panel body is hidden with a display none style

Greetings! I am currently facing an issue while debugging my testing site. The problem is that the expansion panels are not displaying due to a style attribute attached to the div element of v-expansion-panel__body. Strangely, this issue does not occur on ...

Validating date ranges with jQuery UI datepicker: the sequence of activities

Utilizing Jörn Zaefferer's jQuery validation plugin in conjunction with the jQuery UI datepicker, I have created custom rules to validate that a start date comes before an end date. The problem arises when I change a date using the datepicker UI to ...

Implementing event handling for external modules using on method in Node.js

I have been utilizing the request module (available at https://www.npmjs.com/package/request) for executing a series of http requests in my application. However, I am currently facing an issue while attempting to integrate a logging feature into it. I am s ...

Using JavaScript to open a new window and display CSS while it loads

I am looking to utilize a new window for printing a portion of HTML content. var cssLink = document.getElementByTagName('link')[2]; var prtContent = document.getElementById('print_body'); var WinPrint = window.open(' ...

serverless with Node.js and AWS encountering a 'TypeError' with the message 'callback is not a function'

Within my handler.js file, I am utilizing the getQuotation() function from the lalamove/index.js file by passing the string "hi" as an argument. 'use strict'; var lalamove = require('./lalamove/index.js'); module.exports.getEstimate = ...

comparative analysis: nextjs getServerSideProps vs direct API calls

Trying to grasp the fundamental distinction between getServerSideProps and utilizing useSWR directly within the page component. If I implement the following code snippet in getServerSideProps: export const getServerSideProps = async () => { try { ...

Creating a Frontend Base URL with Javascript for Development, APIs, and Production

Is there a way to create a universal base URL that is compatible with various protocols, local environments, ports, and live domains, no matter the stage of development or deployment? ...

Can you show me a comprehensive list of all the REST endpoints for Express mounted Apps?

When working with Express 4, you can utilize the app._router.stack object to list your app routes. In one of the routes in my todos module routes file, I attempted to display this object by sending it as part of the response: exports.update = (req,res) = ...