In my use of Typescript
, I've encountered significant differences between Release Mode
and Debug Mode
. In Debug Mode
, I typically utilize the basic URL
of http://localhost:port/
. However, in Release Mode
, I'm required to switch to https://www.example.com/
Main Challenge
The constant need to alter URLs and other parameters manually between Release Mode
and Debug Mode
is becoming repetitive. This manual intervention may lead to misconfigurations and errors.
Desired Solution
I am seeking a solution that eliminates the need for manual configurations in both Release Mode
and Debug Mode
.
Possible Solutions and Suggestions
Exploring the possibility of using Macros
in Typescript
or similar techniques used in MsBuild
or WebConfig
could be beneficial. For instance, utilizing something like $(ConfigurationName)
or $(ProjectDir)
.
Preferred Outcome
An effortless solution that doesn't require extensive learning or alterations in project architecture. If the use of webpack
is necessary, detailed guidance on its implementation would be appreciated.
Project Framework
Development environment includes Asp.net .Net Framework
or Asp.Net Core
Minimal Reproducible Code
Consider the scenario where only the following URL needs to be modified:
const URL = http://localhost:port/
To:
const URL = https://www.example.com/
Specifically in Release Mode
Potential Complicated Solutions
According to suggestions by @Kaca992, incorporating webpack might address the issue by implementing
mode: 'development'
and mode: 'production'
as shown below:
module.exports = {
mode: 'development'
};
Additional information on production and development modes can be found here
However, this approach has some drawbacks:
- Requires time investment to learn
webpack
- Familiarity with fundamental concepts of npm is needed
- Understanding bundling and minification concepts is essential
- Working knowledge of modules (Import/Export) is required