iGitScor / webpack-content-replacer-plugin

⭐️ Plugin that replace content in file in a webpack workflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add exception levels

iGitScor opened this issue · comments

Hi,

this plugin should have several exception levels

Exceptions

When an exception is caught, all the webpack build failed.
It should be nice if we could configure this behavior

Exception level

  • Strict: actual behavior. If the plugin fails, the webpack build crashes
  • None: no exception are caught and only a warning message is displayed in the console (if the silent mode is not activated)
  • Log: log errors in a log file (and also display a warning message like the none level)

Not forgive to add test

Thank you

Hi @iGitScor. I can take this work if no one else is currently working on it. I'll do some research first and discuss with you about the approach to do it. Thanks

Hi @YQBird,

Nobody has started working on it, so yes you can take this.
If you need help, please ask me 😉

Thank you

@iGitScor. My understanding here is that if plugin fails, the webpack build will still work in None & Log level. Only warning or log file is created. Is this correct?

Yes, that's correct. The main complexity will be to handle rights to write logs.

In the future we'll can potentially add clean log feature.

Hi @iGitScor. I'm thinking two approach here. The first one is to use process global object to catch the uncaught exception. When this event happens, a callback will be called to log or write log to file.
The second one is to integrate with winston npm module, depending on the exception level, different logger will be create. we can use some built-in function from this module and add log level.
Which one do you think is a better approach?

Hi,

I briefly read the documentation of Winston package and it seems to fit our need and the package is enough mature to be integrated. I am not 100% sure but I would choose for the second solution.
We'll see by the usage of it if it can be kept.

Hi. I personally prefer second approach as well. I'll start to work on that.

hi @iGitScor. Being really busy recently. I did some attempt to get exception level from constructor but find it's very difficult to get that argument and use it. I'm think to config exception level as a process.env variable, then use this variable in the core file. Any advice here ?

Hi,

I did some attempt to get exception level from constructor but find it's very difficult to get that argument and use it

do not hesitate to share gist to illustrate your difficulties.

I was thinking of this approach

Hi @iGitScor, here is what I have tried with this issue. https://github.com/YQBird/webpack-content-replacer-plugin/tree/add_exception_level. But I don't find a way to properly setting the log and do the testing yet. I am thinking if it is overkill to use winston for this issue. I will try to use NodeJS process object to solve this. Will keep you update.

Hi @YQBird,

what do you mean ?

I don't find a way to properly setting the log