Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Prettier on README.md #13

Merged
merged 1 commit into from Aug 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions README.md
Expand Up @@ -2,7 +2,6 @@

> [Gulp](http://gulpjs.com) plugin to preprocess HTML, JavaScript, and other files based on custom context or environment configuration


## Information

<table>
Expand All @@ -19,7 +18,6 @@
</tr>
</table>


## Usage

### Install
Expand All @@ -28,24 +26,25 @@
npm install gulp-preprocess --save-dev
```


## Examples

#### Gulpfile

```js
var preprocess = require('gulp-preprocess');
var preprocess = require("gulp-preprocess");

gulp.task('html', function() {
gulp.src('./app/*.html')
.pipe(preprocess({context: { NODE_ENV: 'production', DEBUG: true}})) //To set environment variables in-line
.pipe(gulp.dest('./dist/'))
gulp.task("html", function() {
gulp
.src("./app/*.html")
.pipe(preprocess({ context: { NODE_ENV: "production", DEBUG: true } })) // To set environment variables in-line
.pipe(gulp.dest("./dist/"));
});

gulp.task('scripts', function() {
gulp.src(['./app/*.js'])
gulp.task("scripts", function() {
gulp
.src(["./app/*.js"])
.pipe(preprocess())
.pipe(gulp.dest('./dist/'))
.pipe(gulp.dest("./dist/"));
});
```

Expand Down Expand Up @@ -73,37 +72,38 @@ gulp.task('scripts', function() {
#### Example JavaScript File

```js
var configValue = '/* @echo FOO */' || 'default value';
var configValue = "/* @echo FOO */" || "default value";

// @ifdef DEBUG
someDebuggingCall()
someDebuggingCall();
// @endif
```

CoffeeScript files are also supported.


#### More Examples

`gulp-preprocess` uses [preprocess](https://github.com/jsoverson/preprocess#directive-syntax). More examples can be found in its [README](https://github.com/jsoverson/preprocess#directive-syntax).


## API

### preprocess(options)

#### options.context

Type: `Object`
Default: `{}`

Context for directives used in your preprocessed files. The default context consists of the current user environment variables. Custom context is merged with `process.env`.

#### options.includeBase

Type: `String`

Base directory for included files. By default, the path to included files is relative to the file currently being processed.

#### options.extension

Type: `String`

Override the file extension. This determines what [regular expressions are used for comments](https://github.com/jsoverson/preprocess/blob/master/lib/regexrules.js). You may wish to do this if you are using a custom extension or need to force a particular comment syntax (for example, to allow HTML-style comments in `.php` files).
Expand Down