Skip to content

Sample use of .htaccess in order to compile TypeScript files on-the-fly.

License

Notifications You must be signed in to change notification settings

ComFreek/ts-htaccess

Repository files navigation

What's that?

Sample use of a .htaccess file in order to compile TypeScript files on-the-fly using PHP.

You only need to write script.ts in your HTML and the request will be forwarded to the PHP script. This script will then load a cached version or recompile it.

How to use this sample

  1. Install Node.js if you have not done yet: http://nodejs.org/.
  2. Install TypeScript using NPM: npm install -g typescript.
  3. Put the whole repository on your (local) server.
  4. Open http://your.server/ts-htaccess/index.html in your browser.

How to use TSCompiler.class.php

If you want the output to get written into a file: TSCompiler::compile($options, $errorInfo);

And if you just want a string: $str = TSCompiler::compileToStr($options, $errorInfo);

The passed $options array can contain two values at the moment:

  • $options['inputFile'] The input file
  • $options['outputFile'] The output file which won't be used if you call the string function variant.

You can also specify a temp directory in the class file. The files which are temporarily generated by TSCompiler::compileToStr() will be saved for a very short moment in this location.

About

Sample use of .htaccess in order to compile TypeScript files on-the-fly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages