grunt-npmcopy

npm for the front-end without the cruft.
- Use npm as your front-end package manager without making
node_modules public.
- Position your front-end dependencies where you want them in your repository.
- Conveniently facilitates tracking your front-end dependencies.
Workflow
Whenever you add a new front-end dependency with npm, add which file should be copied and where to your Gruntfile "npmcopy" config. Then, run grunt npmcopy.
Getting Started
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-npmcopy --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-npmcopy');
Note: have a look at load-grunt-tasks so you can skip this step for all your grunt plugins.
The "npmcopy" task
Overview
In your project's Gruntfile, add a section named npmcopy to the data object passed into grunt.initConfig().
grunt.initConfig({
npmcopy: {
options: {
},
your_target: {
}
}
});
Options
options.srcPrefix
Type: String
Default value: 'node_modules'
srcPrefix will prefix your source locations with the correct folder location.
options.destPrefix
Type: String
Default value: ''
destPrefix will be used as the prefix for destinations.
options.report
Type: Boolean
Default value: false
To help ensure you didn't miss any, report any modules in your package.json that have not been configured to copy at least one file with npmcopy.
options.copyOptions
Type: Object
Default value: {}
Options to pass to grunt.file.copy when copying the files. See grunt.file.copy
Usage Examples
grunt.initConfig({
npmcopy: {
test: {
options: {
destPrefix: 'test/js'
},
files: {
'libs/chai.js': 'chai/lib/chai.js',
'mocha/mocha.js': 'libs/mocha/mocha.js',
'mocha/mocha.css': 'libs/mocha/mocha.css'
}
},
libs: {
options: {
destPrefix: 'public/js/libs'
},
files: {
'jquery.js': 'jquery/jquery.js',
'require.js': 'requirejs/require.js'
},
},
plugins: {
options: {
destPrefix: 'public/js/plugins'
},
files: {
'jquery.chosen.js': 'chosen/public/chosen.js'
}
},
less: {
options: {
destPrefix: 'less'
},
files: {
src: 'bootstrap/less/dropdowns.less'
}
},
images: {
options: {
destPrefix: 'public/images'
},
files: {
'account/chosen-sprite.png': 'chosen/public/chosen-sprite.png',
'account/chosen-sprite@2x.png': 'chosen/public/chosen-sprite@2x.png'
}
},
folders: {
files: {
'public/js/libs/lodash': 'lodash',
'public/js/libs': 'lodash/dist/lodash.js'
}
},
glob: {
files: {
'public/js/libs/lodash': 'lodash/dist/*.js'
}
},
globSrc: {
options: {
destPrefix: 'public/js/libs'
},
src: 'lodash/**/*.js'
},
main: {
src: 'jquery.minlight:main',
dest: 'public/js/plugins/'
}
}
});
Contributing
Follow the same coding style present in the repo and add tests for any bug fix or feature addition.
See the CONTRIBUTING.md for more info.
Release History
- 0.1.0 (6-23-2014) First Release
License
Copyright (c) 2014 Timmy Willison. Licensed under the MIT license.