webpack react process.env always empty (windows 10)

后端 未结 1 1782
既然无缘
既然无缘 2021-01-02 05:24

I have read all of the articles here at stack overflow and about 200 more from google searches and i, for the life of me, can\'t get my head around process.env. No matter wh

相关标签:
1条回答
  • 2021-01-02 06:13

    The DefinePlugin configuration you're using replaces occurrences of process.env.NODE_ENV expressions in your code with whichever value you configure - it won't touch references to process.env, as you haven't told it to do anything with that exact expression - the configuration you're using is just shorthand for replacing multiple expressions which share a common root.

    Webpack is detecting that you're referencing a global process variable and is injecting the process mock from node-libs-browser, which as you can see defines an empty env object.

    You can use node Webpack config to control this. Adding node: {process: false} to your config will disable injection of a mock for process.

    0 讨论(0)
提交回复
热议问题