# @boehs/gulp-js-text-inject

> Fixed version of text-inject

Latest version **1.0.3** (published 2022-03-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @boehs/gulp-js-text-inject
pnpm add @boehs/gulp-js-text-inject
yarn add @boehs/gulp-js-text-inject
bun add @boehs/gulp-js-text-inject
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-03-28 |
| First published | 2022-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Benny Bottema |
| Maintainers | boehs |
| Keywords | gulpplugin, js-text-inject, embed-data |

## Links

- npm: https://www.npmjs.com/package/@boehs/gulp-js-text-inject
- Repository: https://github.com/boehs/gulp-js-text-inject
- Issues: https://github.com/boehs/gulp-js-text-inject/issues
- npm.io page: https://npm.io/package/@boehs/gulp-js-text-inject

## Dependencies (3)

- [xtend](https://npm.io/package/xtend.md) ^4.0.0
- [through2](https://npm.io/package/through2.md) ^0.6.5
- [@boehs/gulp-js-text-inject](https://npm.io/package/@boehs/gulp-js-text-inject.md) ^1.0.2

## Recent versions

- 1.0.3 (latest) — 2022-03-28
- 1.0.2 — 2022-03-27

## README

# gulp-js-text-inject

This is a small Gulp plugin for injecting text files right directly into your .js code as strings.

## What is it

The simplest example. JS code:

```js
var template = '@@import template.txt';
var fragment = '@@import src/fragments/fragment.html';
var jsonConfig = '@@import config.json';
```

...and Gulp task:

```js
var gulp = require('gulp');
var inject = require('gulp-js-text-inject');

gulp.task('js', function() {
    return gulp.src('path/to/your/js/*.js')
        .pipe(inject({
            basepath: 'path/to/your/templates/'
        }))
        .pipe(gulp.dest('path/for/output'));
});
```

If we use this plugin, the resulting JS will be:

```js
var template = 'Hello World!\n\nHow are you!';
var fragment = '<div>\n   <p>Hello World!</p>\n   <p>How are you!</p>\n</div>';
var template = '{\n   "config": true,\n   "moreConfig": false\n}';
```

## Changing the import pattern

```js
var myLog = Loader.load('myLog.log');
```

Config to match `Loader.load`:

```js
var gulp = require('gulp');
var inject = require('gulp-js-html-inject');

gulp.task('js', function() {
    return gulp.src('path/to/your/js/*.js')
        .pipe(inject({
            basepath: 'path/to/your/js/',
            pattern: /Loader.load\(['"]([a-zA-Z0-9\-_.\\/]+)['"]\)/g
        }))
        .pipe(gulp.dest('path/for/output'));
});
```

## Options

Option | Type | Default | Details
------ | ---- | ------- | -------
basepath | string | `""` | Base path to look up referenced templates from
pattern | RegExp | `/'@@import ([a-zA-Z0-9\-_.\\/]+)'/g` | Pattern to match template references. Should have one capture group that will match template path
relative | boolean | `false` | Resolve templates relative to the file being processed
debug | boolean | `false` | Displays some information while working - processed files, found references, injection result

---
_Source: https://npm.io/package/@boehs/gulp-js-text-inject · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
