{"id":15527240,"url":"https://github.com/endenwer/npm-rails","last_synced_at":"2025-08-26T00:11:56.867Z","repository":{"id":56885817,"uuid":"49061295","full_name":"endenwer/npm-rails","owner":"endenwer","description":"NPM support for Rails with Bundler-like DSL","archived":false,"fork":false,"pushed_at":"2016-06-09T15:14:50.000Z","size":30,"stargazers_count":83,"open_issues_count":0,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-12-10T02:10:35.997Z","etag":null,"topics":["browserify","npm","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/endenwer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-05T11:16:38.000Z","updated_at":"2024-11-30T05:48:26.000Z","dependencies_parsed_at":"2022-08-21T00:50:14.372Z","dependency_job_id":null,"html_url":"https://github.com/endenwer/npm-rails","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endenwer%2Fnpm-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endenwer%2Fnpm-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endenwer%2Fnpm-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endenwer%2Fnpm-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/endenwer","download_url":"https://codeload.github.com/endenwer/npm-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230431100,"owners_count":18224655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browserify","npm","rails"],"created_at":"2024-10-02T11:05:09.643Z","updated_at":"2024-12-19T12:09:52.865Z","avatar_url":"https://github.com/endenwer.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# npm-rails\n\n[![Gem Version](https://badge.fury.io/rb/npm-rails.svg)](https://badge.fury.io/rb/npm-rails)\n[![Code Climate](https://codeclimate.com/github/endenwer/npm-rails/badges/gpa.svg)](https://codeclimate.com/github/endenwer/npm-rails)\n[![Dependency Status](https://gemnasium.com/endenwer/npm-rails.svg)](https://gemnasium.com/endenwer/npm-rails)\n[![Build Status](https://travis-ci.org/endenwer/npm-rails.svg?branch=master)](https://travis-ci.org/endenwer/npm-rails)\n[![Coverage Status](https://coveralls.io/repos/github/endenwer/npm-rails/badge.svg?branch=master)](https://coveralls.io/github/endenwer/npm-rails?branch=master)\n\nNPM support for Rails projects. It let you use Bundler-like DSL and rake tasks\nfor including npm packages. This gem based on Browserify for bundling packages\nand resolve dependencies.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'npm-rails'\n```\n\nThen run:\n\n    rails g npm_rails:initialize\n\nAnd require `npm-dependencies.js`:\n\n    //=require npm-dependencies\n\n## Usage\n\n1. Add a package to `npm_packages` file\n2. Run `rake npm:install`\n3. Use the package in your javascript code by calling the camelize name\nor `build_name` if you set it\n\n**Example `npm_packages` file**\n\n```ruby\n# call 'React' in your js code to use it\nnpm 'react'\n\n# Set version\nnpm 'redux', '3.3.1'\n\n# Set build_name to a package.\n# Call '_' to get Underscore\nnpm 'underscore', build_name: '_'\n\n# You can add a package for development\nnpm 'jasmine', development: true\n\n# Or in block\ndevelopment do\n  npm 'jasmine'\nend\n\n# Install a package but do not require it\nnpm 'browserify', require: false\n```\n\n## Configuration Options\n\nThe following options are available for configuration in your application or environment-level\nconfig files (`config/application.rb`, `config/environments/development.rb`, etc.):\n\n| Configuration Option                      | Description                                                                                                                                  |\n|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------- |\n| `config.npm.package_file`                 | Specificies a package file. Default value: `npm_packages`                                                                                    |\n| `config.npm.output_file`                  | Specifies a file where to bundle npm packages. Default value for production: `vendor/assets/javascripts/npm-rails/production/npm-dependencies.js`. Default value for other environments: `vendor/assets/javascripts/npm-rails/development/npm-dependencies.js`                               |\n| `config.npm.browserify_options`           | Sets options for browserify command. See all available options in [Browserify documentation](https://github.com/substack/node-browserify#usage) |\n| `config.npm.run_before_assets_precompile` | If set to `true` then run `rake npm:install` before assets precompilation. Default value: `false` |\n\n## How it works\n\nThe generator creates `npm_packages` file. This file contains a list of packages. Rake uses NPM to install the packages and Browserify to bundle them. Browserify output the bundled results to `output_file`(see configuration options), which are then loaded by sprockets. All packages attached to `window` by `build_name`, which by default is the camelize package name.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendenwer%2Fnpm-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendenwer%2Fnpm-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendenwer%2Fnpm-rails/lists"}