Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matzeeable/grunt-node-modules-cachebuster
:star2: Generates a file containing node module versions for node_modules defined in your package.json.
https://github.com/matzeeable/grunt-node-modules-cachebuster
cachebuster grunt grunt-task npm
Last synced: about 12 hours ago
JSON representation
:star2: Generates a file containing node module versions for node_modules defined in your package.json.
- Host: GitHub
- URL: https://github.com/matzeeable/grunt-node-modules-cachebuster
- Owner: matzeeable
- License: mit
- Created: 2017-11-07T15:28:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-05T08:07:03.000Z (about 5 years ago)
- Last Synced: 2024-10-08T02:18:09.466Z (about 1 month ago)
- Topics: cachebuster, grunt, grunt-task, npm
- Language: JavaScript
- Homepage: https://matthias-web.com
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Grunt Node Modules Cachebuster
This tasks reads a folder of node package names subfolders and creates a file (`json`or `php`) with **key** (package name) **value** (version) pairs. An example use case is a project where you copy `js` and `css` files to a `library` folder from the `node_modules` folder. The webapp clients should then always load the latest version of the package files whenever they change (`npm update`). The plugin requires [**grunt**](https://gruntjs.com/).## Getting started
Simply install via:
```sh
$ npm install grunt-node-modules-cachebuster --save-dev
```## Example task
Imagine the `public/lib` folder contains this subfolders (copied from `node_modules` via [`grunt-contrib-copy`](https://github.com/gruntjs/grunt-contrib-copy)): `react`, `react-dom`. Your `Gruntfile.js` can define a task like the below:```js
node_modules_cachebuster: {
'publiclib': {
options: {
banner: '/* This file was automatically generated (' + new Date().toString() + '). */',
format: 'php'
},
src: ['public/lib/*'],
dest: 'inc/others/cachebuster-lib.php'
}
}
```
The task above can result in (`cachebuster-lib.php`):
```php
'16.0.0',
'react-dom' => '16.0.0'
);
```## API
* `options.format` (_string_): `php` or `json` format. This format will be the output for the `dest` file.
* `options.banner` (_string_): This text will be prepended to the output.
* `options.altNodeModules` (_string_): Relative path to another `node_modules` folder, for example to work with hoisting (lerna, yarn workspaces)## License
This grunt task is MIT licensed. The project is inspired by this project: [grunt-cachebuster](https://github.com/felthy/grunt-cachebuster).