Environment Variables in an isomorphic JS app: Webpack find & replace?

后端 未结 4 964
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 08:32

I\'m using webpack to bundle an isomorphic JS app (based on this example) so that the browser runs the same code as the server. Everything is running smoothly except I have

4条回答
  •  一个人的身影
    2020-12-29 09:09

    Yeah; looks like envify-loader was the easy solution.

    I just added the following to my webpack loaders:

    {
      test: /config\.js$/, loader: "envify-loader"
    }
    

    And the config.js (and only that file) is modified to include any referenced environment variables statically :)

提交回复
热议问题