Skip to content

How to use variables with different values for production? #66

@oren

Description

@oren

I am switching to preact-cli from the preact boilerplate and I noticed that there is no webpack configuration file. The only missing feature for me is the ability to change the URL of my server: during development I am accessing localhost:3000 and during production api.my-server.com. With the preact boilerplate I use webpack's DefinePlugin:

new webpack.DefinePlugin({
  'process.env.NODE_ENV': JSON.stringify(ENV),
  'API_HOST': (ENV === 'production') ? JSON.stringify('https://api.my-server.com') : JSON.stringify('http://localhost:3000')
}),

(Here is the code as part of the entire project)

How do I achieve the same capability with preact-cli? I don't mind not using webpack at all. I know it can be done with grep and sed but that might not work on windows machines.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions