
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
laravel-mix-make-file-hash
Advanced tools
Convert the default Laravel Mix querystring hashing to filename hashing.
By default, the hashing system in Laravel Mix will append a querystring to the filename to invalidate the cache.
Example from mix-manifest.json
:
{
"/dist/main.js": "/dist/main.js?id=1e70e7c11a9185f57e64"
}
The problem is that this way of hashing may not work with some caching systems.
Instead, "Laravel Mix make file hash" will move the hash into the filename of the hashed files. So your mix-manifest.json
will look something like this:
{
"/dist/main.js": "/dist/main.1e70e7c11a9185f57e64.js"
}
To accomplish the re-hashing, this script will:
mix-manifest.json
generated by Laravel Mix.mix-manifest.json
with the new filenames.Turn on debug to activate noisy feedback:
{ debug: true }
Install package from npmjs.com:
npm i -D laravel-mix-make-file-hash
# or
yarn add laravel-mix-make-file-hash -D
if (mix.inProduction()) {
mix.version();
mix.then(() => {
const convertToFileHash = require("laravel-mix-make-file-hash");
convertToFileHash({
publicPath: "web",
manifestFilePath: "web/mix-manifest.json"
});
});
}
convertToFileHash
returns a Promise containing the new mix-manifest.json
contents. This means you can perform another task after the convertToFileHash
has finished the re-hashing.
if (mix.inProduction()) {
mix.version();
mix.then(async () => {
const convertToFileHash = require("laravel-mix-make-file-hash");
const fileHashedManifest = await convertToFileHash({
publicPath: "web",
manifestFilePath: "web/mix-manifest.json"
});
// Do something here...
});
}
Name | Type | Default | Description |
---|---|---|---|
publicPath * | string | undefined | The path to your public folder (eg: "web" ) |
manifestFilePath * | string | undefined | The filePath to your mix-manifest.json (eg: "web/mix-manifest.json" ) |
fileTypesBlacklist | string /array | undefined | A list of filetypes to ignore re-hashing |
keepBlacklistedEntries | boolean | false | Whether to keep blacklisted entries in the manifest |
delOptions | object | { force: false } | Options to provide to del - See options |
debug | boolean | false | Debug exactly what's happening (or meant to happen) during runtime |
* = Required
if (mix.inProduction()) {
mix.version();
mix.then(async () => {
const convertToFileHash = require("laravel-mix-make-file-hash");
convertToFileHash({
publicPath: "web",
manifestFilePath: "web/mix-manifest.json",
fileTypesBlacklist: ["html"],
keepBlacklistedEntries: true,
delOptions: { force: false },
debug: false
});
})
This script was created for the Agency Webpack Mix Config.
FAQs
Convert the default Laravel Mix querystring hashing to filename hashing.
The npm package laravel-mix-make-file-hash receives a total of 2,778 weekly downloads. As such, laravel-mix-make-file-hash popularity was classified as popular.
We found that laravel-mix-make-file-hash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.