https://github.com/mikedevelops/file-catalogue
Create a JSON file within your build directory with an array of files passed through the Webpack.
https://github.com/mikedevelops/file-catalogue
nodejs webpack
Last synced: 3 months ago
JSON representation
Create a JSON file within your build directory with an array of files passed through the Webpack.
- Host: GitHub
- URL: https://github.com/mikedevelops/file-catalogue
- Owner: mikedevelops
- Created: 2017-02-21T20:58:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-02T11:41:38.000Z (over 9 years ago)
- Last Synced: 2025-02-28T23:58:38.157Z (over 1 year ago)
- Topics: nodejs, webpack
- Language: JavaScript
- Homepage:
- Size: 184 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# File Catalogue
Create a JSON file within your build directory with an array of files passed through the Webpack compiler.
### Installation
`npm install mikedevelops/file-catalogue`
### Usage
_assets/_
```
| assets
- foo.jpg
- bar.png
```
_webpack.config.js_
```javascript
const FileCatalogue = require('file-catalogue')
module.exports = {
// ... your config
plugins: [
new FileCatalogue({
filename: 'assets',
test: /\.(jpg|png)$/
})
]
}
```
_assets.json_
```javascript
{"assets":["foo.jpg","bar.png"]}
```
### Options
----
`filename: [string] | default: assets.json`
The name of the output catalogue file. Directories will be resolved, `bar/foo` will place `foo.json` in a directory named `bar` within the build directory.
----
`test: [RegExp]`
A regular expression to be run against each file that passes through the Webpack compiler. If no test is provided all files will be pushed to the catalogue.
----
### What problem does this solve?
This plugin was created to solve a problem with pre-loading and caching assets on a native iOS app (built with Phonegap). Unlike the web, I was unable to access a directories contents with a XHR request.
Building this plugin allowed me to request the catalogue file with a XHR request, parse, then preload and cache each asset on the device.