Reduce the use of javascript by incorporating NPM specifically after publishing instead of during the building process

My goal is to minify JS files using NPM commands, but I want the minify command to only run after Post Publish and not on Build. Unfortunately, it currently runs after both build and publish. In my Package.json file, I have the following code:

"scripts": {
    "uglify": "recursive-uglifyjs ./Scripts/src/"
}

I have added a new DefaultTarget in my .csproj file:

<Project ToolsVersion="12.0" DefaultTargets="Build;AfterPublish"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

And here is the code for the target:

 <Target Name="AfterPublish" AfterTargets="MSDeployPublish">
<Exec Command="npm run uglify " />
<Exec Command="echo $(Configuration)"></Exec>
<Exec Command="echo testing..after publiosh " />

Unfortunately, when running this, it minifies the JS files after both build and publish. What I actually need is for it to only happen after publishing.

If you have any suggestions or see where I might be going wrong, please let me know!

Answer №1

To resolve an issue with the project DefaultTargets, consider removing "AfterPublish" and making adjustments to the AfterTargets property as shown below:

<Target Name="AfterPublish" AfterTargets="GatherAllFilesToPublish">
<Exec Command="npm run uglify " />
<Exec Command="echo $(Configuration)"></Exec>
<Exec Command="echo testing..after publish " />

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

What are some ways to personalize a scrollbar?

I am looking to customize the scrollbar within a div. I attempted to modify it using the code below, but I encountered difficulties when trying to change the scroll buttons and did not achieve my desired outcome. Additionally, this customization did not wo ...

When an AJAX call is made during a PHP session that has timed out

I am working on an AJAX form that handles data authentication. In the event of a session timeout, I need to implement a redirect to the login page. How can I go about achieving this? Here is an excerpt from my simplified server-side code: function doExecu ...

Is there a way to pass locale data using props in VueJS Router?

To access hotel data, the URL path should be localhost:8080/hotel/:id (where id is equal to json.hoteID). For example, localhost:8080/hotel/101 This path should display the specific data for that hotel. In order to achieve this, we will utilize VueJS vu ...

Steps to prevent specific links from being clickable in React Native's webview component

In my React Native app, I am utilizing the react-native-webview component to display blog posts. The code I have implemented is straightforward, but my goal is to restrict the webview to only show content from the blog section of the website, preventing us ...

Issue with React and Material UI: The Textfield's "onChange" event is not being triggered

I have been attempting to trigger an onchange function when my Textfield is populated, but for some reason the function never seems to be activated. Despite seeing changes triggered by the React devtool plugin in Chrome, I am at a loss. Any suggestions? i ...

Implementing long polling for private messaging in PHP's chat functionality

Can you help me with a question I have regarding my chat form on the HTML page? Here is the code for the form: <form action="../addchat.php" method="POST" enctype="multipart/form-data"> <textarea id="textarea" style="border- ...

Utilizing HttpWebRequest for URL encoding with ISO-8859-1 character encoding

I'm encountering an issue with HttpWebRequest not utilizing ISO-8859-1 encoding for parameters in a web request, which pertains to both POST and GET methods. In essence, the problem lies in the fact that any parameter in the request containing non-as ...

When sending a form with a POST request in NODE, the data can be missing

I'm having trouble with setting up routes in an API and getting data from simple forms. Take a look at this basic HTML form: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8> <title>test form</titl ...

React's createRef() versus callback refs: Which one provides the ultimate edge in performance?

Lately, I've delved into React and grasped the concept of refs for accessing DOM nodes. The React documentation discusses two methods of creating Refs. Could you elaborate on when a callback ref is preferable to createRef()? Personally, I find createR ...

Addressing the issue of prolonged Electron initialization

Scenario After spending considerable time experimenting with Electron, I have noticed a consistent delay of over 2.5 seconds when rendering a simple html file on the screen. The timeline of events unfolds like this: 60 ms: app ready event is triggered; a ...

Need a jQuery function that updates the 'id' after clicking on a specific div? Here's how to do it!

I need help simplifying my current situation. Step 1: I want to increment the variable "count" by 1 every time a specific div is clicked. Step 2: After updating "count", I want to utilize it in another function. This function involves copying the value f ...

Does LABJS include a feature for executing a callback function in the event of a timeout during loading?

When using LabJS to asynchronously load scripts with a chain of dependencies, if one of the scripts breaks (due to download failure or connection timeout), it seems that the remaining scripts in the chain will not be executed. Is there a way to define a ...

AJAX request: No values are being returned by $_GET

After spending hours trying to figure this out... I've been working on using AJAX to grab values from a jQuery slider within an <input> tag. The AJAX request is not failing (see code below), and when I use console.log to check the variable I&ap ...

Discovering ways to determine if multiple strings are present within a single string using JavaScript

After writing this function, I noticed it only worked with a single string value. contains(input, words) { let input1 = input.split(' '); for (var i = 0; i < input1.length; i++) { if (input1[i] === words) { ...

Moving a div horizontally while clicking and holding on a control button with a smooth animation effect

I am currently working on a new feature inspired by a previous question I found on Stack Overflow. My goal is to make the scrolling start slowly and then gradually speed up. However, I am facing an issue with using easing in the animate function as it get ...

Node Package Manager (NPM): Easily Importing Files from a Package

Is there a way to customize the file import paths within a package? I am working with a UI kit package for our internal project and after building with Webpack, my project structure looks like this: - dist - components - index.d.ts - index.js Prior ...

When using AngularJS filter, the comparator will evaluate to true and display the ng-repeat list even when the input

Recently, I stumbled upon this interesting example fiddle showcasing the use of a comparator parameter to filter exact matches: http://jsfiddle.net/api/post/library/pure/ The priority is supposed to be a number between 1-100, but due to inputting it as t ...

Only two options available: validate and hide; no additional options necessary

Having some trouble understanding the logic behind a JavaScript script that is meant to display select options based on another select option. Any tips on how to hide unused options? For example: If TV is selected, only show options for device, tsignal, b ...

Handling Exceptions Globally in a .NET Core Console Application

I'm currently in the process of migrating a console application to .NET Core, and I am facing an issue with replacing this line: AppDomain.CurrentDomain.UnhandledException += UnhandledException; After perusing through this article, it appears that t ...

Steer clear of utilizing the AutodiscoverUrl method in the Microsoft Exchange Service

On some remote machines, certain users are encountering an exception when calling the AutodiscoverUrl() method: An exception has been thrown by the target of an invocation at SystemRunTimeMethodHandle.InvokeMethod. InnerException: The user name or passwo ...