kswoll / WootzJs

C# to Javascript Compiler implemented via Roslyn
MIT License
110 stars 21 forks source link

Additional Conditional compilation symbols from Command Line #18

Closed Danielku15 closed 9 years ago

Danielku15 commented 9 years ago

It would be great if you could specify additional conditional compilation symbols from the commandline. An example usecase could be to compile a reflection and minified-reflection version from the same project file:

AssemblyInfo.cs

#if MINIMIZE
[assembly:JsCompilerOptions(AreAutoPropertiesMinimized = true, AreDelegatesMinimized = true, IsReflectionMinimized = true)]
#endif

Invocation

WootzJs.Compiler.exe $(ProjectPath) $(OutDir)
copy "$(TargetDir)$(TargetName).js" "$(SolutionDir)Build\$(TargetName).js"
WootzJs.Compiler.exe $(ProjectPath) $(OutDir) define=MINIMIZE
copy "$(TargetDir)$(TargetName).js" "$(SolutionDir)Build\$(TargetName).min.js"

Multiple constants could look like this define=MINIMIZE_REFLECTION,MINIMIZE_AUTOPROPERTIES,MINIMIZE_DELEGATES

kswoll commented 9 years ago

I think this is a great idea and I like how this design will work. I'll look into implementing this today.

kswoll commented 9 years ago

This has been implemented as described. I also modied WootzJs.Runtime AssemblyInfo to provide if def sections for each property of JsCompilerOptionsAttribute.