Closed iamyigitkoc closed 2 years ago
Great work investigating this @iamyigitkoc. We'll take a look at your workaround and do some of our own investigation into this. I had a feeling that Windows paths might not be handled by the new functionality as most of its functionality operates on the CLI level, although we had hoped that PHP (or Symfony Process) might've handled a fair few of the gotchas.
I can confirm that the patched commands from @iamyigitkoc work's for me.
php artisan mix:compile -p theme-workshop
Mixing package "theme-workshop
Laravel Mix
Build successful
Glad to hear it! Can someone submit the patches as a single PR to this repo?
I can do it this weekend. I will also test it on linux based OS wether it breaks previous builds or not.
I can do it this weekend. I will also test it on linux based OS wether it breaks previous builds or not.
Any news @iamyigitkoc ?
I can do it this weekend. I will also test it on linux based OS wether it breaks previous builds or not.
Any news @iamyigitkoc ?
I had a personal urgency, just updated the code. Gonna test the code then open the PR.
Can someone validate the build on a linux machine if it works as expected?
Thank's for this PR @iamyigitkoc !!
Winter CMS Build
1.1
PHP Version
8.0
Database engine
MySQL/MariaDB
Plugins installed
Issue description
Summary
Laravel Mix implementation has issues on Windows 10. The newly implemted "mix:compile" and "mix:watch" commands have many issues preventing mix feature running. [Exact PHP version 8.0.14]
Bug 1:
First of all, I found out that path concatenations are not cross platform safe. Because of this bug, relative paths can't be concatenated and the returnes something like "C:\path\to\root\C:\path\to\root\themes\foo-bar/mix.webpack.js".
Example issue from code:
Should be:
(PHP should have handled conversion but it didn't in this case)
Following classes in System module have this issue.
Error message and log:
Bug 2:
After fixing the each one of the concatenations, compilation process couldn't run webpack.js in bin directory. A windows execution error window appeared on screen for "Microsoft JScript Error". "Trying to execute a script..." page on stackoverflow entry had some temporary solutions however system default is an issue. Thus, I tried to find main issue.
"System\Console\MixCompile->createCommand()" tries to execute webpack directly however Windows does not start this script with Node.js. I tried removing .JS from PATHEXT but it didn't workout. Then selected node.exe as default program for .js files. It kind of worked but it was not a good workaround.
I removed webpack.js path then added "npx mix build/watch", changed "--config" to "--mix-config" and removed '--progress'; this worked for me. Still, this is not a good execution command.
Error Message:
Bug 3:
require() function can't find 'laravel-mix' module when MixCompile executes the process. I didn't understand, but require removes the seperators in path somehow.
Error message:
Additional note:
Steps to replicate
Workaround
I provided some kind of "fixed" code in wn-laravel-mix-error-fix for Bug 1 and Bug 2 seperately.
fixed-for-windows branch is a workaround that makes running "php artisan mix:compile" or "php artisan mix:watch" possible.
The last bug was caused by singular '\'. Window's separator was not revesed or escaped in webpack config file created via fixture. To fix this issue I added addslashes() escape function to every path value replaced in config file.
Last words
Edit 1:
Created a complete workaround.