makestatic-sources-loader
Version:
Loads source files from disc
116 lines (80 loc) • 3.17 kB
Markdown
# Sources Loader
> Load file sources into the pipeline
Adds input files to the pipeline.
---
- [Install](#install)
- [API](#api)
- [SourcesLoader](#sourcesloader)
- [.before](#before)
- [.sources](#sources)
- [Options](#options)
- [Throws](#throws)
- [License](#license)
---
## Install
```
yarn add makestatic-sources-loader
```
## API
### SourcesLoader
Initializes the source files that will be processed.
#### .before
```javascript
SourcesLoader.prototype.before(context)
```
Propagates the list of files to process.
If the configuration option `files` is an array it is used otherwise all
files in the `input` directory are added to the list of files to process.
* `context` Object the processing context.
#### .sources
```javascript
SourcesLoader.prototype.sources(file, context[, options])
```
Reads a file from disc.
If the file name matches a pattern in the `matchers` configuration option
if is assigned the corresponding file extension so that it will be
renamed when the file output path is set.
If the file name matches a pattern in the `ignore` configuration option
it is removed from the list of files to process.
If the file points to a directory it is removed from the list of files to
process.
By default this implementation will read the file content and assign the
buffer to the `file.buffer` and set the initial `file.content` unless the
`buffer` option is disabled.
If the `buffer` option is disabled the file will still be assigned
a `stat` object.
Returns a promise that resolves when the file has been read.
* `file` Object the current file.
* `context` Object the processing context.
* `options` Object plugin options.
##### Options
* `load` Boolean=true the file buffer.
##### Throws
* `Error` if the stat fails.
* `Error` if the file read fails.
## License
MIT
---
Created by [mkdoc](https://github.com/mkdoc/mkdoc) on March 12, 2017
[docs]: https://makestatic.ws/docs/ "Documentation"
[standalone manual]: https://github.com/makestatic/website/blob/master/MANUAL.md "Standalone Manual"
[yarn]: https://yarnpkg.com "Yarn"
[webpack]: https://webpack.js.org "Webpack"
[babel]: https://babeljs.io "Babel"
[postcss]: http://postcss.org "Postcss"
[sugarss]: https://github.com/postcss/sugarss "Sugarss"
[reshape]: https://github.com/reshape/reshape "Reshape Source Code"
[reshapeml]: https://reshape.ml "Reshape"
[clean-css]: https://github.com/jakubpawlowicz/clean-css "Clean CSS"
[html-minifier]: https://github.com/kangax/html-minifier "Html Minifier"
[uglify-js]: https://github.com/mishoo/UglifyJS2 "Uglify JS"
[imagemin]: https://github.com/imagemin/imagemin "Imagemin"
[mkdoc]: https://github.com/mkdoc/mkdoc "Mkdoc"
[browsersync]: https://www.browsersync.io "Browsersync"
[yeoman]: http://yeoman.io "Yeoman"
[spike]: https://www.spike.cf "Spike"
[validator]: https://github.com/validator/validator "HTML Validator"
[github pages]: https://pages.github.com "Github Pages"
[amazon s3]: https://aws.amazon.com/s3/ "Amazon S3"
[google sitemaps]: https://support.google.com/webmasters/answer/183668?hl=en&ref_topic=4581190 "Google Sitemaps"
[sitemaps]: https://www.sitemaps.org/ "Sitemaps"