A nil module variable won't compile inside a library

In my library I have a plug that contains a condition and other plugs in it:

Simplified code:

defmodule MyLibWeb.MyPlug do
  use Plug.Builder

  if System.get_env("MIX_ENV") != "prod" do
    @cfg Application.get_env(:my_lib, :key1)

    plug(Plug.Static,
      at: @cfg[:path1],
      from: @cfg[:path2]
    )

  # [...............]
  end
end

And then in my a client application:

defmodule MyAppWeb.Endpoint do
  use Phoenix.Endpoint, otp_app: :my_app

  plug MyLibWeb.MyPlug

Before, during 1-2 years, it’s compiled and worked.

Now it won’t compile due to @cfg:

== Compilation error in file lib/my_app_web/my_plug.ex ==
** (FunctionClauseError) no function clause matching in String.split/3    
    
    The following arguments were given to String.split/3:
    
        # 1
        nil
    
        # 2
        "/"
    
        # 3
        []
    
    Attempted function clauses (showing 3 out of 3):

Why won’t it? @cfg is inside a library and @cfg will be provided by a client who uses a library; of course it’s nil now, in a library.

How to fix it?

Isn’t this the same question as the one you posted here an hour ago: If and unless behave differently - compilation error

I would add other information to that topic and not create a new question for it.