Sergei Basharov
Sergei Basharov

Reputation: 53850

How to write a variable into my code with Webpack?

I have a set of files that are compiled into a bundle file. The frontend code is in its own repository and I have some information about it when building the bundle.

I want to put that information into my bundle so that it's accessible from the code, like

App.Env = 'development'

then access it like this:

if (App.Env === 'development') {
    Api.Url = 'http://stating.example.com'
}

Upvotes: 0

Views: 26

Answers (1)

Prakash Sharma
Prakash Sharma

Reputation: 16472

You can use define webpack plugin. https://github.com/webpack/docs/wiki/list-of-plugins#defineplugin

Upvotes: 1

Related Questions