Skip to content

[Asset] PathPackage combined with JsonManifestVersionStrategy not sitable with laravel-mix manifest #36234

Closed
@glensc

Description

@glensc

Description

Laravel Mix provides a fluent API for defining Webpack build steps for your Laravel application using several common CSS and JavaScript pre-processors.

The mix manifest is created with a leading slash:

{
    "/dist/main.js": "/dist/main.js?id=ecfe06d840525bff34b2",
    "/dist/main.css": "/dist/main.css?id=5b13608ecbc9f614ba25"
}

This file is compatible with JsonManifestVersionStrategy,
however PathPackage to prepend path expects input to be without leading slash.

Example

// I expect to get as result: /example/dist/main.js?id=ecfe06d840525bff34b2

$manifestPath = 'mix-manifest.json';
$relativeUrl = '/example';
$versionStrategy = new JsonManifestVersionStrategy($manifestPath);
$package = new PathPackage($relativeUrl, $versionStrategy);

// returns /dist/main.js?id=ecfe06d840525bff34b2 because leading slash
var_dump($package->getUrl("/dist/main.js"));

// returns "/example/dist/main.js" because no match in manifest
var_dump($package->getUrl("dist/main.js"));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions