Search code examples
phplaravellaravel-mix

The Mix manifest does not exist when it does exist


For my admin panel I extract all the assets including the manifest-json.js to mix.setPublicPath(path.normalize('public/backend/')).

All the files get correctly added to the backend folder, and the manifest-json.js file looks as follows:

{
    // all correct here
    "/js/vendor.js": "/js/vendor.js",
    "/js/app.js": "/js/app.js",
    "/css/app.css": "/css/app.css",
    "/js/manifest.js": "/js/manifest.js"
}

the problem is that when using

{{ mix('backend/css/app.css') }}

in my blade-files, it looks in public/manifest-json.js instead of looking for it in backend/manifest-json.js.

How can I make sure the right manifest-json.js file is used?


Solution

  • The problem I faced was that the mix()-helper function by default looks for the manifest-json file in /public/manifest-json.js so if you store that file on any other directory level then it will throw that error.

    Let's say the manifest-json file is stored in public/app/manifest-json.js, then for a file located in public/app/css/app.css you would use:

    <link rel="stylesheet" href="{{ mix('css/app.css', 'app') }}">
    

    The mix()-helper function allows for a second argument, the directory of the manifest file. Just specify it there and it will use the correct manifest file.