This is an Iris and typescript bridge plugin.
- Search for typescript files (.ts)
- Search for typescript projects (.tsconfig)
- If 1 || 2 continue else stop
- Check if typescript is installed, if not then auto-install it (always inside npm global modules, -g)
- If typescript project then build the project using tsc -p $dir
- If typescript files and no project then build each typescript using tsc $filename
- Watch typescript files if any changes happens, then re-build (5|6)
Note: Ignore all typescript files & projects whose path has '/node_modules/'
- Bin: string, the typescript installation path/bin/tsc or tsc.cmd, if empty then it will search to the global npm modules
- Dir: string, Dir set the root, where to search for typescript files/project. Default "./"
- Ignore: string, comma separated ignore typescript files/project from these directories. Default "" (node_modules are always ignored)
- Tsconfig: config.Tsconfig{}, here you can set all compilerOptions if no tsconfig.json exists inside the 'Dir'
- Editor: config.Typescript { Editor: config.Editor{}, if setted then alm-tools browser-based typescript IDE will be available. Defailt is nil
All these are optional
package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/config"
"github.com/kataras/iris/plugin/typescript"
)
func main(){
ts := config.Typescript {
Dir: "./scripts/src",
Tsconfig: config.Tsconfig{Module: "commonjs", Target: "es5"},
}
// or config.DefaultTypescript()
iris.Plugins().Add(typescript.New(ts)) //or with the default options just: typescript.New()
iris.Get("/", func (ctx *iris.Context){})
iris.Listen(":8080")
}
Enable web browser editor
ts := config.Typescript {
//...
Editor: config.Editor{Username:"admin", Password: "admin!123"}
//...
}