WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Laravel Mix plugin that replaces all the assets URLs with the corresponding hashed one generated by version()

Notifications You must be signed in to change notification settings

TangoDev-it/laravel-mix-version-apply

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Mix Version Apply Plugin

Laravel Mix plugin that replaces all the assets URLs with the corresponding hashed one generated by version().

This plugin is mainly meant to be used in a CI/CD workflow.

Install

npm i laravel-mix-version-apply

Usage

let mix = require('laravel-mix');
require('laravel-mix-version-apply');

mix 
    .setPublicPath('.')
    .sass('src/app.scss', 'dist/')
    .js('src/app.js', 'dist/');

if (mix.inProduction()) {
    mix
        .version()
        .versionApply(['index.html']);
}

API

.versionApply(fileInput)

With fileInput you can specificy the files in which you want to replace the assets URL. Supported formats are:

  • Array of strings
  • Glob string
  • Single string

Result

Before versionApply():

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Laravel Mix Version Apply Plugin</title>
    <link rel="stylesheet" href="/dist/app.css">
</head>
<body>
    <h1>Laravel Mix Version Apply Plugin</h1>
    <script src="/dist/app.js"></script>
</body>
</html>

After versionApply():

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Laravel Mix Version Apply Plugin</title>
    <link rel="stylesheet" href="/dist/app.css?id=082fcf4a96cc981bfab1">
</head>
<body>
    <h1>Laravel Mix Version Apply Plugin</h1>
    <script src="/dist/app.js?id=b5a3764d979b90fe8dd7"></script>
</body>
</html>

About

Laravel Mix plugin that replaces all the assets URLs with the corresponding hashed one generated by version()

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published