Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"The Mix manifest does not exist." since upgrade #262

Closed
krodelabestiole opened this issue Oct 26, 2020 · 5 comments
Closed

"The Mix manifest does not exist." since upgrade #262

krodelabestiole opened this issue Oct 26, 2020 · 5 comments
Assignees
Labels

Comments

@krodelabestiole
Copy link

hi, I get this error when trying to display the frontend with a theme that used to work on wordplate 7.0 and no longer on wordplate 9. I could not find anything related to laravel mix in the upgrade guides.

here is my webpack.mix.js :

const mix = require('laravel-mix');
require('dotenv').config();
const theme = process.env.WP_THEME;

mix.setResourceRoot('../');
mix.setPublicPath(`public/themes/${theme}/assets`);

mix
  .copyDirectory('resources/assets/img', `public/themes/${theme}/assets/img`)
  .copyDirectory('resources/assets/fonts', `public/themes/${theme}/assets/fonts`)

mix
  //.disableNotifications()
  .js('resources/assets/scripts/app.js', 'scripts')
  .sass('resources/assets/styles/app.scss', 'styles')
  .version();

(theme name is tp)
when running yarn run dev everything seems to be copied and compiled successfully . mix-manifest.json is created in public/themes/tp/assets/mix-manifest.json

but then running these functions in functions.php :

wp_enqueue_style('app', mix('styles/app.css'));
wp_register_script('app', mix('scripts/app.js'), '', '', true);

always returns this error :

Fatal error: Uncaught Exception: The Mix manifest does not exist.
in /srv/www/tp/wordplate/vendor/ibox/mix-function/index.php on line 12

Call stack:

mix()
public/themes/tp/functions.php:143

do you have any clue about this ?

@vinkla
Copy link
Owner

vinkla commented Oct 27, 2020

Did you install the ibox/mix-function package with Composer? The second argument to the mix() function is where the mix-manifest.json file is located.

@vinkla vinkla self-assigned this Oct 27, 2020
@krodelabestiole
Copy link
Author

thanks a lot for your feedback !

Did you install the ibox/mix-function package with Composer?

yes, sure !

The second argument to the mix() function is where the mix-manifest.json file is located.

ok thanks for the tip, which doesn't seem to be documented at all...

mix() function works when specifying an absolute path :

wp_enqueue_style('app', mix('styles/app.css','/srv/www/tp/wordplate/public/themes/tp/assets'));

but I can't find any relative path that would do :

wordplate/public/themes/tp/assets
public/themes/tp/assets
themes/tp/assets
tp/assets
assets

what is this path relative to ?
mix-manifest.json is created in the setPublicPath directive value. however it doesn't seem to be looked for there by the mix() function...

@krodelabestiole
Copy link
Author

... from what I understand from the first condition in the mix function, $manifestDirectory has to be an absolute path (starting with a /) otherwise a leading / will be added.

if ($manifestDirectory && strpos($manifestDirectory, '/') !== 0) {
    $manifestDirectory = "/{$manifestDirectory}";
}

and from what I understand from this part :

if (! file_exists($manifestPath = $manifestDirectory.'/mix-manifest.json')) {
     throw new Exception('The Mix manifest does not exist.');
}

is that if $manifestDirectory is empty (by default), the function will look for the absolute /mix-manifest.json and returns an error when it does not exist (well, of course it doesn't).

I guess I'm completely wrong somewhere...

@vinkla
Copy link
Owner

vinkla commented Oct 27, 2020

Does it work? Maybe you could use the magic constant __DIR__ or the get_theme_file_path function.

@krodelabestiole
Copy link
Author

oh sure you're right !
great then, it works !

wp_enqueue_style('app', mix('styles/app.css', __DIR__.'/assets'));

many thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants