Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leduong/gulp-ts-config
Typescript configuration generator
https://github.com/leduong/gulp-ts-config
Last synced: about 1 month ago
JSON representation
Typescript configuration generator
- Host: GitHub
- URL: https://github.com/leduong/gulp-ts-config
- Owner: leduong
- License: mit
- Created: 2016-08-05T02:04:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-24T18:40:26.000Z (over 7 years ago)
- Last Synced: 2024-11-17T14:41:27.292Z (2 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# gulp-ts-config
[![Paypal](https://img.shields.io/badge/donate-paypal-blue.svg)](https://goo.gl/mgesnb)
[![Gratipay Team](https://img.shields.io/badge/give-a%20cup%20of%20coffee-b35900.svg)](https://gratipay.com/Angular-VN)[![License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://npmjs.org/package/gulp-ts-config)
[![NPM version](http://img.shields.io/npm/v/gulp-ts-config.svg?style=flat)](https://npmjs.org/package/gulp-ts-config)
[![NPM version](http://img.shields.io/npm/dm/gulp-ts-config.svg?style=flat)](https://npmjs.org/package/gulp-ts-config)
[![Build Status](http://img.shields.io/travis/leduong/gulp-ts-config.svg?style=flat)](http://travis-ci.org/leduong/gulp-ts-config)
[![Coverage Status](https://coveralls.io/repos/leduong/gulp-ts-config/badge.svg?branch=master&service=github)](https://coveralls.io/github/leduong/gulp-ts-config?branch=master)
[![dependencies Status](https://david-dm.org/leduong/gulp-ts-config/status.svg)](https://david-dm.org/leduong/gulp-ts-config)[![NPM](https://nodei.co/npm/gulp-ts-config.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/gulp-ts-config/)
It's often useful to generate a file of constants, usually as environment variables, for your Angular apps.
This Gulp plugin will allow you to provide an object of properties and will generate an Angular module of constants.## To Install:
`npm install gulp-ts-config`## How it works
It's pretty simple:
`gulpTsConfig(moduleName)`## Example Usage
We start with our task. Our source file is a JSON file containing our configuration. We will pipe this through `gulpTsConfig` and out will come an angular module of constants.
```javascript
var gulp = require('gulp');
var gulpTsConfig = require('gulp-ts-config');gulp.task('test', function () {
gulp.src('appsettings.json')
.pipe(gulpTsConfig('AppSettings'))
.pipe(gulp.dest('.'))
});
```
Assume that `appsettings.json` contains:
```json
{
"ApiEndpoint": "http://localhost:5000/api"
}
```
Running `gulp test` will take `appsettings.json` and produce `appsettings.ts` with the following content:```ts
export class AppSettings {public static get ApiEndpoint(): string {
return "http://localhost:5000/api";
}
}
```
We now can include this configuration module in our main app and access the constants
```ts
import { AppSettings } from 'appsettings';
```## Configuration
Currently there are a few configurable options to control the output of your configuration file:
- [options.environment](#options.environment)
- [options.constants](#options.constants)
- [options.createModule](#options.createModule)
- [options.type](#options.type)
- [options.wrap](#options.wrap)
- [options.parser](#options.parser)
- [options.pretty](#options.pretty)This is copy from [Atticus White](https://github.com/ajwhite/gulp-ng-config) @robinpowered
Thanks