Skip to content

cli-v1.7.2

Latest

Choose a tag to compare

@seho-dev seho-dev released this 13 Feb 12:57
· 30 commits to master since this release

1.7.2

Minor Changes

  1. 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")
// @endif

conditional 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

  1. 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

i4qah-4qds2