-
Notifications
You must be signed in to change notification settings - Fork 6
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
Check unreadable manifest to enable dev mode [CakePHP 4] #17
base: master
Are you sure you want to change the base?
Check unreadable manifest to enable dev mode [CakePHP 4] #17
Conversation
Hi, thanks for your PR! :) First, you bring a good point to the table that there should not be an exception happening when first using the plugin without ever have run the vite command (i.e., the manifest.json does not exist). Or do you never have a manifest locally and only bundle assets in production? I'd be interested to hear about your use case/setup! :) After taking a short look, it seems weird to me that devMode is just assumed if the Manifest does not exist. This should never happen in production, e.g. if there is no manifest for whatever reason. Also, I don't really like this "exception driven development" where you just use the I can look into it on the weekend if I find the time. But until then the Exception is the better solution than just assuming you are in dev mode imo. As far as I remember the error message is also quite clear that a manifest must be created. |
Maybe other people have an opinion on this? @bor-attila @jbennecker |
You could as well look if the file exists in your app's config and set the |
Hi @passchn, thank you for starting a discussion. Our use case is as follows: without a stringent convention for the use of virtual hosts in local development, the Therefore, our need would be to force development mode regardless of the host name.
Generally, we do use the dev server, but occasionally, for debugging, we create a local bundle to be more similar to the production environment.
I totally agree with your objection. I thought it could work as I expect the
Here too, I agree. I was a bit conservative, I didn't want to refactor the In addition to the |
To the current PR: I think it's ok to assume production mode based on manifest - bcz in prod always exists, and in dev shouldn't. In worst case/mistake
PR is ok, but still not flexible enough. My solution/idea: Few weeks ago I ran into a problem. My friend wanted to use dev mode meanwhile his 'boss' checking the prod. I already forked the repo and I started to rethink all this 'is prodution' or 'is dev' thingy. So far I removed the I set up an
With a detector (callback + ServerReqeust param) literally you can solve everything. IP, cookie detection, env variable, path, query, action, etc ... Sadly my solution is not compatible with the current config/version (maybe after a PR new major version ?!). |
I'm totally fine with rethinking the config and planning a new major. Like 3.x for Cake4 and 4.x for Cake5. I personally am not using devMode all the time locally. Also, I try to think about it and make my own PR which I will link here for discussion. I think environments might be the clearest way to go. Then, the config keys About the method exposal as @edoardocavazza mentioned: This is depending on the config, because there could e.g. be a manifest from a CakePHP plugin. The whole config and options handling in the helper is a bit overengineered imo currently.. Maybe this could also be simplified :) It is a bit cumbersome to use this vite plugin within other plugins, I did it here: https://github.com/passchn/cakephp-file-pool/blob/cake5/templates/element/helper/FilePool.php It works - but maybe the stuff could be simplified. Anyways, great to hear you are using the plugin actively! :) |
This PR introduces a new
development.checkManifest
param. Whentrue
(defaults tofalse
for backward compatibility) the helper will look for manifest readability in order to detect dev mode.This is a proposal PR, I'll create the cake 5 version once this has been approved.