zouhir / jarvis

A very intelligent browser based Webpack dashboard
5.44k stars 191 forks source link

Use JARVIS conditionally for dev & prod #117

Closed deadcoder0904 closed 6 years ago

deadcoder0904 commented 6 years ago

Not sure if its a Webpack thing or JARVIS thing, but here it is.

Currently I'm using a environment variable JARVIS & to include it I use a boolean true

Complete example is https://github.com/deadcoder0904/webpack-exam

So my questions is -

Is there any way I can refactor the line https://github.com/deadcoder0904/webpack-exam/blob/master/package.json#L8 to not send JARVIS=true as environment variable ? What I mean by this is if I am using webpack-dev-server in the script use jarvis & if I'm using webpack in the script don't use it without using env variable JARVIS.

Also, I think examples might help this repo to make it better. Like simple example with dev, prod & base config working with jarvis & complex one working with express, etc...

I will be happy to contribute 😉

zouhir commented 6 years ago

I understand your question, unfortunately the only way to handle that is in your config \ NODE_ENV.

Jarvis works like any other plugin and runs once it exists in the plugins array in your webpack config file and they way you have done it is actually the right way, I don't know of any better idea but here are what we can do:

1- instead of passing JARVIS=true you can rely if --watch exist or not, and in your base configs you you can probably check of this is --watch mode: https://stackoverflow.com/a/5767589

2- another option is, we can add disable option to Jarvis, but we still need a flag from you on when to disable it and it will end up very similar to what you have.

Please let me know if I can help further more!

deadcoder0904 commented 6 years ago

Cool I thought there would be a better way though 😂

stephencookdev commented 6 years ago

@zouhir might it make sense to only run Jarvis in watch mode by default? i.e. by booting it up in compiler.plugin("watch-run", ...), rather than where it sits atm in the root apply?

Maybe worth considering with me https://github.com/zouhir/jarvis/pull/122 to make the option be something like options.onlyRunInWatchMode (awful name, but you get my point) which defaults to true? And then when sets to false it will boot up Jarvis regardless of watch mode or not, and not close the server as soon as the build finishes?

stephencookdev commented 6 years ago

I've raised https://github.com/zouhir/jarvis/pull/125 as a possible example of what I mean. Hopefully something like this could solve both this issue, and https://github.com/zouhir/jarvis/pull/122?

stephencookdev commented 6 years ago

I believe that with 0.3.0 Jarvis should behave as described here

Unless the watchOnly option is set to false, then Jarvis won't run when just running a non-watching build

So this ticket should be fine to close?

zouhir commented 6 years ago

yep! can be closed!