Skip to content

michaelpwilson/sails-hook-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sails-hook-typescript

Sails JS hook to compile & watch TypeScript files.

Installation

npm install sails-hook-typescript

Usage

requires at least sails >= 0.11

Just lift your app as normal, and when you add / change / remove a TypeScript file inside assets/js, the file will be re-compiled and the browser will be reloaded (if you have Live Reload) without having to lower / relift the app.

Configuration

By default, configuration lives in sails.config.typescript. The configuration key (typescript) can be changed by setting sails.config.hooks['sails-hook-typescript'].configKey.

Parameter Type Details
active ((boolean)) Whether or not the hook should compile & watch for TypeScript file changes. Defaults to true.
usePolling ((boolean)) Whether or not to use the polling feature. Slower but necessary for certain environments. Defaults to false.
compilerOptions ((object)) Options to the typescript compiler. You can learn more about these options in Using the Compiler API and Compiler Options.
dirs ((array)) Array of strings indicating which folders should be watched. Defaults to the assets/js,
ignored ((array|string|regexp|function)) Files and/or directories to be ignored. Pass a string to be directly matched, string with glob patterns, regular expression test, function that takes the testString as an argument and returns a truthy value if it should be matched, or an array of any number and mix of these types. For more examples look up anymatch docs.

Example

// [your-sails-app]/config/typescript.js
var ts = require('typescript');

module.exports.typescript = {
  active: true,
  usePolling: false,
  compilerOptions: {
    module: ts.ModuleKind.System
  },
  dirs: [
    "assets/js",
    "assets/js/dependencies",
  ],
  ignored: [
    "assets/js/directorytoignore"
  ]
};

That’s it!

About

Sails JS hook to compile TypeScript files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •