![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
grunt-bower-main
Advanced tools
Adds only the main files from Bower components to source code. Integrates seamlessly with grunt-wiredep.
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-bower-main --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-bower-main');
In your project's Gruntfile, add a section named bower_main
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
bower_main: {
copy: {
options: {
dest: 'src/resources/bower_components'
}
}
}
})
Type: String
Default value: 'copy'
Dictates whether the main files will be copied to a destination directory ('copy'), or if other files will be removed from the bower_components directory ('prune').
The default location for the bower_components directory is the top level directory. Setting method to 'copy' will
allow you to keep the bower_components directory and copy the main files into your source code. This is useful if you
are not using a static frontend stack (like a Java webapp for example). If you don't care about keeping the original
component files then you can set your bower_components directory to live directly in the source code and prune away
unnecessary files. This method keeps the 'bower.json' and '.bower.json' files also so that bower install
does not
reinstall them every time.
Type: String
Default value: null
This must be set if using method: 'copy', will be the top-level destination directory of the main files.
Type: String
Default value: '.tmp'
This is used with method: 'prune'. The plugin copies main files here, deletes the bower_components directory, and renames this directory to 'bower_components' (or whatever the original bower components directory was named.) Change this if you are using '.tmp' for any other plugin.
Type: String
Default value: '.bowerrc'
Points to your .bowerrc file if you have one.
Type: Object
Default value: undefined
Specify main file overrides. This can also be set in your project's bower.json in the same format, but options take precedent:
overrides: {
fontawesome: {
main: './css/font-awesome.css' //exclude fonts
},
bootstrap: {
main: ['dist/js/bootstrap.js'] //exclude styles
}
}
This task is generally used in tandem with grunt-wiredep. Run this task first, and then configure wiredep as you normally would. This is possible because the directory structure of the output of this task is identical to the original. The motivation to create this task comes from working in a Java house and we wanted to pull the bower_components out of the artifact, but still be able to use wiredep.
To get started quickly, just set a 'dest' directory:
grunt.initConfig({
bower_main: {
copy: {
options: {
dest: 'src/resources/bower_components'
}
}
}
})
If you want to prune instead, just tell it to prune and change the temp directory if necessary:
grunt.initConfig({
bower_main: {
prune: {
options: {
method: 'prune',
tmpDir: 'pruneTmp'
}
}
}
})
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Copyright (c) 2014 Ben March. Licensed under the MIT license.
FAQs
Adds only the main files from Bower components to source code.
The npm package grunt-bower-main receives a total of 267 weekly downloads. As such, grunt-bower-main popularity was classified as not popular.
We found that grunt-bower-main demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.