Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fourlabsldn/dep-linker
Copy your npm dependencies to server them to the front-end.
https://github.com/fourlabsldn/dep-linker
Last synced: 5 days ago
JSON representation
Copy your npm dependencies to server them to the front-end.
- Host: GitHub
- URL: https://github.com/fourlabsldn/dep-linker
- Owner: fourlabsldn
- Created: 2016-05-13T15:03:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-30T19:40:03.000Z (about 4 years ago)
- Last Synced: 2024-10-04T15:04:44.989Z (about 1 month ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dependencies Linker
[![npm](https://img.shields.io/npm/v/dep-linker.svg?maxAge=2592000)](https://www.npmjs.com/package/dep-linker)
[![npm](https://img.shields.io/npm/dt/dep-linker.svg?maxAge=2592000)](https://www.npmjs.com/package/dep-linker)
[![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000)](https://www.npmjs.com/package/dep-linker)Link your npm dependencies to serve them to the front-end.
Automatically link your project's dependency files to a folder like `public/scripts`
so that you can serve them to the front end.## Install
```
npm install --save-dev dep-linker
```## Use
``` javascriptvar depLinker = require('dep-linker');
depLinker.linkDependenciesTo('./public/scripts')
.then(() => console.log('Finished.'));
// Done! All your dependencies ready to be served to the front-end
```
*dev-dependencies are not linked*.## Task runners
There still isn't a specific wrapper for any task runner, but given that this
is just javascript for now you can use it like this and it will work like a charm:### Gulp
``` javascript
var depLinker = require('dep-linker');gulp.task('link-dependencies', function () {
return depLinker.linkDependenciesTo('./public/scripts');
});
```### Grunt
``` javascript
var depLinker = require('dep-linker');grunt.task.registerTask('link-dependencies', 'Copy npm dependencies', function () {
var done = this.async(); // <-- must be async
return depLinker.linkDependenciesTo('public/scripts')
.then(() => done())
.catch(() => done());
});```
## Options
### Set root folder
`dep-linker` gets your dependencies from your `package.json` which is in your project's
root folder. If the script is not being run from the root folder, specify the path
to it:``` javascript
var depLinker = require('dep-linker');
depLinker.setRoot('../../');
```