Wrong assets paths showing when using laravel mix with the Laravel Modules

  laravel, laravel-mix, laravel-models, php

I have setup the project on the subdomain like https://example.com/newapi. Also i have setup the module in the project OrderManagement with command composer require nwidart/laravel-modules
it has created all the file structure in the OrderMangement folder. Also i can use the routes with
https://example.com/newapi/ordermanagement

But facing issue assets with laravel mix and it’s showing the 404 file not found.

Step 1: npm install laravel-mix-merge-manifest –save-dev inside the ordermanagement folder

Step 2: npm run dev

enter image description here
master.blade.php

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Module OrderManagement</title>

       {{-- Laravel Mix - CSS File --}}
       {{-- <link rel="stylesheet" href="{{ mix('css/ordermanagement.css') }}"> --}}

    </head>
    <body>
        @yield('content')

        {{-- Laravel Mix - JS File --}}
        {{-- <script src="{{ mix('js/ordermanagement.js') }}"></script> --}}
    </body>
</html>

webpack.mix.js

const dotenvExpand = require('dotenv-expand');
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/ }));

const mix = require('laravel-mix');
require('laravel-mix-merge-manifest');

mix.setPublicPath('../../public/').mergeManifest();
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/ordermanagement.js')
    .sass(__dirname + '/Resources/assets/sass/app.scss', 'css/ordermanagement.css');

if (mix.inProduction()) {
    mix.version();
}

Also i applied solution of setResourceRoot() in the mix from help of below link but it also not working .
Please help me how to setup laravel mix with laravel module in subfolder.

https://github.com/JeffreyWay/laravel-mix/issues/1026

Source: Laravel

Leave a Reply