Can someone provide guidance on minifying certain files with laravel-mix?

Is there a way to selectively minimize certain files using laravel-mix? According to the documentation, you can minify files by running npm run prod. I specifically want to minify the file a.js but not b.js. Can this be achieved through the webpack.mix.json configuration file or the npm command alias in package.json?

Versions:

[email protected]

[email protected]

[email protected]

Answer №1

this is a sample showcasing how to compress specific documents

const mix = require('laravel-mix');

// 1. Example with one source file and one output path.
mix.js('src/app.js', 'dist/app.js');

// 2. Combining multiple source files to be bundled together:
mix.js([
    'src/app.js',
    'src/another.js'
], 'dist/app.js');

// 3. Handling multiple entry and output points:
mix.js('src/app.js', 'dist/')
   .js('src/forum.js', 'dist/');

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

The Angular Animation constantly resets with each new action taken

In my Angular project, I am working on a scaling animation for a list. I want the animation to only trigger when specific buttons (red and green) are pressed. Currently, the animation restarts regardless of what I click on. Can anyone help me troubleshoot ...

Getting the final element in Selenium Webdriver with JavaScript

When I create a script to confirm the successful addition of an element, I always find that the added element is positioned at the end of the page or becomes the last element in a different div. In this case, I am utilizing selenium webdriver and javascrip ...

The Javascript style.opacity function eliminates the leading zero from the input string

In my application, users have the ability to change the color of the background but not the pattern. They can adjust the background behind the pattern and the opacity of the pattern. Users are prompted to input a percentage, which is actually a number betw ...

In the year 2021, eliminate linked documents using mongoose/MongoDB middleware

After extensive research on stack overflow, I attempted various solutions for deleting referenced documents in MongoDB using node.js. Unfortunately, most of them either utilize deprecated methods or simply do not function as expected. Within my applicatio ...

The ReactJS Application Cache Client fails to display the most recent updates

One issue I'm currently facing is with my application in production. Some clients have reported that they are unable to see the new changes unless they clear their cache completely. Using Techs: React Any suggestions on what steps I should take to a ...

Connect select with an array of objects and showcase information when an item is chosen from the dropdown menu

I have an array $scope.items= [ { name: "Jon Snow", email: "jon@example.com", password: "WinterIsComing" }, { name: "Daenerys Targaryen", email: "daenerys@example.com", password: "FireAndBlood" } ]; Now, I am trying to show the email value in a dropdown ...

Is there any other directory besides node_modules that npm interacts with during the local package installation process?

I am interested in learning about the process of installing packages locally within a project instead of globally. Can someone explain whether there are distinct differences between running npm uninstall some-package compared to simply deleting the some-p ...

Acquiring the root URL with the $location service in AngularJS

I am facing a situation where I have a specific URL structure like the one shown below. http://localhost:8080/test#/users/list Upon further investigation, I discovered the following information: $location.url() returns -> "users/list" $location.path( ...

Transforming the AngularJS $http GET method to OPTION and including custom headers

var users= $resource('http://myapp.herokuapp.com/users', {}); users.get(); The change in the HTTP GET method to OPTION occurred after implementing a header method. var users= $resource('http://myapp.herokuapp.com/users', {}, { get ...

Is there a way to fetch and display property changes in Vue Material's md-dialog?

In the component hierarchy, there is a parent component containing a child, which further contains an md-dialog component. The dialog is opened from the parent component using the following code: ParentComponent.vue <template> <div> < ...

The ngOnInit function is not triggered upon instantiation of an Injectable class

What could be causing the ngOnInit() method not to be called upon resolution of an Injectable class? Code import {Injectable, OnInit} from 'angular2/core'; import { RestApiService, RestRequest } from './rest-api.service'; @Injectable ...

What is the best way to automatically build a Single Page Application when deploying to Heroku?

Currently, I am in the process of learning how to deploy my Vue app to Heroku. After deploying my code to Heroku, I am facing a challenge when trying to automatically build my code to the dist/<code> folder. Despite attempting to configure the packag ...

Having trouble with installing the LTS version of Node.js

Having trouble installing the LTS version of Node.js. When I run "node -v", the output is : v7.4.0 However, running "nodejs -v" gives: v4.2.6 In addition, the node installation does not include npm by default. Encountering various issues with Node.js ...

How can I maintain the selected state of checkbox and radio button in ReactJS after page refresh?

I am facing an issue with my multistep form that contains radio buttons and checkboxes from material UI. Although the data is stored correctly in state and local storage, when I move to the next page and then return, the selections appear unselected to the ...

Storing npm dependency in cache through github workflow

Looking to improve efficiency by caching npm dependencies and avoiding unnecessary installs every time there's a push. Wondering if GitHub Actions now support this feature?: How do I cache steps in GitHub actions? Consider the following scenarios: ...

What is the best way to stack several elements on top of each other?

<div class="parent"> <div class="child" id="child-A"> <div class="child" id="child-B"> <div class="child" id="child-C"> </div> The main concept here ...

Working with three.js: Implementing an external texture in a glTF file

In my quest to apply a texture file to a 3D model using three.js, I've hit a roadblock. Despite days of research and numerous attempts, I just can't seem to get it right. Here is the method I've been using to set the current object in the sc ...

Experiencing difficulties with executing numerous NodeJs queries

Could someone assist with rendering multiple queries in a Nodejs view? The console shows Promise {pending} and I can't figure out what's causing the issue. I'd appreciate any help or guidance on how to fix this problem. router.get('/ ...

Utilizing PNG images with color in CSS, HTML, or JavaScript

On my website, I have an image in PNG format. I am wondering if there is a way to change the color of the image using HTML5, JavaScript, or CSS. Ideally, I would like the image to be changed to white by inverting its colors (changing black to white, not al ...

Having trouble getting the Google motion chart to work with asynchronous JSON requests

I have been using the code below to make a request for a JSON file and then parsing it. google.load('visualization', '1', {packages: ['controls', "motionchart", "table"]}); google.setOnLoadCallback(function(){ createTable($(& ...