1.7.2
Minor Changes
- Add conditional compilation function and optimize code package
// @ifdef server || unicloud
console.log("server or unicloud")
// @endif// @ifdef server
console.log("server")
// @endif// @ifndef server
console.log("server")
// @endifconditional compiled code can also be written in other ways
if(process.env._SWORD_PLATFORM === "server"){
// do something...
}Similarly, we used to use useProd and useDev to determine the runtime environment, now we can use the following method to determine the runtime environment, this will be compiled in advance, the generated code will only contain the code of the current environment, in short, it reduces the runtime overhead
if(process.env._SWORD_COMMAND === "build"){
// do something...
// dev / build / doc etc...
}In the latest example, the type hint for the env (src/global.d.ts) has been added to the sample project so that the developer has a good type hint
- Vscode plugin adds conditional compilation code snippets
For conditional compilation, we can write comment macros, or we can make judgments directly on process.env._SWORD_PLATFORM, and when you use comment macros, the latest vscode plugin will help you write comment macros, like this
