New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

laravel-mix-make-file-hash

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

laravel-mix-make-file-hash

Convert the default Laravel Mix querystring hashing to filename hashing.

1.1.0
Source
npm
Version published
Weekly downloads
3.8K
-25.32%
Maintainers
1
Weekly downloads
 
Created
Source

Laravel Mix make file hash

Mix has querystring hashing by default which doesn't work too well with some caching systems.

Querystring hashing looks like this:

(OLD) main.css?id=abcd1234

After mix has done it's thing, this script converts that querystring hashing to filename hashing:

(NEW) main.abcd1234.css

Usage

This is not a Laravel mix plugin so use with mix.then() like this:

if (mix.inProduction()) {

    // Allow versioning in production
    mix.version()

    // Run after mix finishes
    mix.then(() => {
            const laravelMixMakeFileHash = require("laravel-mix-make-file-hash")
            laravelMixMakeFileHash('web', 'web/mix-manifest.json')
    })
}

Options

laravelMixMakeFileHash(
    publicPath,
    manifestFilePath
)

Under the hood

It'll first look at your manifest, then create a new file with the updated hash and then remove the old file.

Most of the code is from tomgrohl on this Laravel Mix issue on querystring hashing

FAQs

Package last updated on 27 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts