https://github.com/vanruesc/grunt-fs-inline
This grunt plugin enables you to use brfs without browserify.
https://github.com/vanruesc/grunt-fs-inline
Last synced: 8 months ago
JSON representation
This grunt plugin enables you to use brfs without browserify.
- Host: GitHub
- URL: https://github.com/vanruesc/grunt-fs-inline
- Owner: vanruesc
- License: zlib
- Archived: true
- Created: 2015-11-22T18:07:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-01T16:09:15.000Z (over 10 years ago)
- Last Synced: 2025-01-17T22:36:03.347Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# grunt-fs-inline
[](https://travis-ci.org/vanruesc/grunt-fs-inline)
[](https://badge.fury.io/js/grunt-fs-inline)
[](https://david-dm.org/vanruesc/grunt-fs-inline)
This grunt plugin enables you to use [brfs](https://github.com/substack/brfs) without browserify. It's useful if you want to
inline external files like shader code in your JavaScript files.
## Getting Started
This plugin requires Grunt >= 0.4.0
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started)
guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins.
Once you're familiar with that process, you may install this plugin with this command:
```sh
npm install grunt-fs-inline --save-dev
```
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
```js
grunt.loadNpmTasks("grunt-fs-inline");
```
## Usage
Specify a source path ```src``` and a destination path ```dest```. __The destination is always relative to the source path.__ Directories
will be created if they don't exist. If you don't specify a clear file name with a file extension in ```dest```, then the name of the source
file will be used instead.
```js
fsinline: {
taskA: {
src: "src/foo.js",
dest: "./foo.inlined.js"
},
taskB: {
src: "src/foo.js",
dest: "../other/dir"
},
...
}
```
### Glob
You may use [glob patterns](https://github.com/isaacs/node-glob#glob-primer) in order to inline a bunch of files at once.
```js
fsinline: {
task: {
src: "src/**/foo.js",
dest: "./bar"
}
}
```
The above configuration will create the sub directory __bar__ wherever files with the name __foo.js__ are found in __src__. The inlined version of
the source file will be written to a new file with the _same name_ in the created directory, because ```dest``` doesn't clearly specify a file name here.
### Options
In addition to the underlying [brfs](https://github.com/substack/brfs#var-tr--brfsfile-opts) and [glob](https://github.com/isaacs/node-glob#options)
options, you may also append an arbitrary text to the inlined files.
```js
fsinline: {
options: {
// Global options.
brfs: { ... },
glob: { ... },
append: "export default foo;"
},
taskA: {
options: {
// Local options.
brfs: null,
glob: null,
append: null
},
src: "src/a.js",
dest: "./a.inlined.js"
},
...
}
```
## Contributing
Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
## License
[Zlib](https://github.com/vanruesc/grunt-fs-inline/blob/master/LICENSE)