What is the right way to enable the REPL browser on a page, but only in development?

I use Austin to configure REPL with a browser connection and follow an example project example that uses Enlive to add a REPL script to a page.

Now I would like to deploy my application, but I do not want Austin or my REPL to be on the page in production. What is the intended way to use REPL in development only?

Is there a way to use Enlive as middleware that I could use in development rather than production?

+6
source share
1 answer

Almost always, something uniquely distinguishes the production environment from :dev , which you can use as a conditional: if in :dev enter the result (browser-connected-repl-js) ; if not, do not do this.

If your deployment environment does not have this property, I would suggest adding it, because this "only in X environment" view uses a case that is often used for many things.


On the other hand, if you want to prevent Austin and his dependencies included in your production chains from completely modifying any of your codes that uses browser-connected-repl-js , one solution might just be Space Austin names, for example:

 (ns cemerick.austin.repls) (defn browser-connected-repl-js [& _] "") 

Put this in cemerick/austin/repls.clj in the directory that is included in your project.clj not :dev profile :source-paths . Now your code will be deployed for production without Austin and its dependencies, and your code will transparently call the above dummy function (do not enter anything into your pages).

+5
source

Source: https://habr.com/ru/post/975334/


All Articles