shyim / shopware-docker

Easy to use Docker Installation for Shopware 5 and Shopware 6
MIT License
115 stars 27 forks source link

storefront-watch not working with production template #177

Closed LiaraAlis closed 1 year ago

LiaraAlis commented 1 year ago

Hi,

using swdc storefront-watch with the production template does not work propably. Accessing the storefront under http://.localhost:9998 the following error occur:

GET http://sw6production.localhost:9998/_webpack_hot_proxy_/js/vendor-node.js net::ERR_ABORTED 404 (Not Found)
GET http://sw6production.localhost:9998/_webpack_hot_proxy_/js/vendor-shared.js net::ERR_ABORTED 404 (Not Found)
GET http://sw6production.localhost:9998/_webpack_hot_proxy_/js/runtime.js net::ERR_ABORTED 404 (Not Found)
GET http://sw6production.localhost:9998/_webpack_hot_proxy_/js/app.js net::ERR_ABORTED 404 (Not Found)
GET http://sw6production.localhost:9998/_webpack_hot_proxy_/js/storefront.js net::ERR_ABORTED 404 (Not Found)
Access to XMLHttpRequest at 'http://sw6production.localhost/_wdt/ed135f' from origin 'http://sw6production.localhost:9998/' was blocked by CORS policy: The request header field x-requested-with is not allowed by access-control-allow headers in the preflight response.
LiaraAlis commented 1 year ago

Maybe we have the same problem here as in https://github.com/dockware/dockware/issues/56?

shyim commented 1 year ago

I didnt had the time to look into it yet

daniel-memo-ict commented 1 year ago

The cause of this problem also happens for the admin watcher running at localhost:8181 instead of admin-projectname.dev.localhost

This all happens because the platform-local module is not being loaded.

On https://github.com/shyim/shopware-docker/blob/v1/swdc#L59 is a file check for src/Kernel.php, a file which no longer exists in newer Shopware versions (tested with 6.4.16.1 and 6.4.12.0, exists in the latter, but not in the former) There's also a check for src/Core/composer.json but that file doesn't exist in either version.

If I comment out both line 59 and 61, so it always include platform-local, then all my problems are solved.

LiaraAlis commented 1 year ago

@shyim As a shopware expert, can you say something about this checks? :P

daniel-memo-ict commented 1 year ago

For reference, the src/Kernel.php file was removed in https://github.com/shopware/production/commit/a9e49a9f87b46b75b5636be68c12d9f30ef83cd3 but it still exists in the development template src/Core/composer.json never seems to have existed at that file location in either the production or the development template

daniel-memo-ict commented 1 year ago

Update: While the watchers are running on the correct urls again, I still have problems with missing assets in the storefront watcher, as initially described by @LiaraAlis

I seem to be missing this piece of code in vendor/shopware/storefront/Resources/app/storefront/build/proxy-server-hot/index.js image

This seems to be because https://github.com/shyim/shopware-docker/blob/v1/modules/platform/hot-proxy-patched.js is replacing that file when running https://github.com/shyim/shopware-docker/blob/v1/modules/platform/storefront-watch.sh#L21

daniel-memo-ict commented 1 year ago

Final update (from me):

Because it fails that src/Kernel.php filecheck mentioned yesterday it runs platform/storefront-watch.sh instead of platform-local/storefront-watch.sh platform/storefront-watch.sh copies the (very old) file hot-proxy-patched.js, which is missing some code, to build/proxy-server-hot/index.js, permanently messing up the hot reload for the project you're running.

Even after fixing the filecheck, if it has already replaced build/proxy-server-hot/index.js in your project, then assets still won't work correctly for that project. Either clone a new production template, or replace the build/proxy-server-hot/index.js with the correct one from https://github.com/shopware/platform/blob/trunk/src/Storefront/Resources/app/storefront/build/proxy-server-hot/index.js

LiaraAlis commented 1 year ago

@shyim I can not confirm that this issue is resolved with this last patch. I think that it is also needed to update the hot-proxy-patched.js as mentioned by @daniel-memo-ict. Using the original file, the watcher is working when executing bin/watch-storefront.sh, even in my case the fonts couldn't be loaded and the size of the page is wrong. But maybe this is a problem with my theme.

shyim commented 1 year ago

But that file should not be copied anymore. rm -rf vendor && composer install

daniel-memo-ict commented 1 year ago

@LiaraAlis Indeed, if you've started the storefront watcher for a project, before getting this fix, then the hot proxy script has been permanently replaced. As @shyim said, removing the vendor folder and doing a composer install will make sure you get the original hot proxy script back. Replacing it manually as I've mentioned before will also work.

@shyim What is/was the use case for the hot-proxy-patched.js file?

shyim commented 1 year ago

It was required for a really old shopware versions before I fixed it in the core

LiaraAlis commented 1 year ago

I did all this mentioned… but I must be stupid because I did it again and now it is working. đŸ˜… Okay, I never said anything. đŸ¤£