README.md in rails_external_assets-0.1.0 vs README.md in rails_external_assets-0.2.0

- old
+ new

@@ -1,21 +1,21 @@ [![Gem Version](https://badge.fury.io/rb/rails_external_assets.png)](http://badge.fury.io/rb/rails_external_assets) [![Build Status](https://secure.travis-ci.org/jdlehman/rails_external_assets.svg?branch=master)](http://travis-ci.org/jdlehman/rails_external_assets) # RailsExternalAssets -RailsExternalAssets allows you to use the frontend build tool of your choice ([webpack](https://webpack.github.io/), [jspm](http://jspm.io/), [browserify](http://browserify.org/) etc) with Rails. Essentially you can build all (or some) of your frontend assets outside of Rails' asset pipeline, but still make use of them in Rails. The only requirement is that you provide an asset manifest file, which is a json file that maps your asset files to their final built files: +RailsExternalAssets allows you to use the frontend build tool of your choice ([webpack](https://webpack.github.io/), [jspm](http://jspm.io/), [browserify](http://browserify.org/), etc) with Rails. Essentially you can build all (or some) of your frontend assets outside of Rails' asset pipeline, but still make use of them in Rails. The only requirement is that you provide an asset manifest file, which is a json file that maps your asset files to their final built files: ```json { "js/module.js": "builds/js/module-12312abc.js", "js/react-component.jsx": "builds/components/react-component-ab123x.js", "css/styling.sass": "builds/styles/styling-129xha.css" } ``` -This means you can manage your frontend assets however you like and RailsExternalAssets gives you [Rails](http://rubyonrails.org/) view helpers and [Sprockets](https://github.com/rails/sprockets) directives to incorporate these external assets into your Rails application. +This means you can manage your frontend assets however you like and RailsExternalAssets gives you [Rails](http://rubyonrails.org/) view helpers and [Sprockets](https://github.com/rails/sprockets) directives to incorporate these external assets into your Rails application. In Rails environments, RailsExternalAssets also hooks into `assets:precompile` and `assets:clobber` Rake tasks. You can use RailsExternalAssets without using Ruby on Rails, but you will have to wire up the helper methods it provides into your application yourself. ## Installation @@ -37,10 +37,12 @@ ## With Rails You can include your external assets in Rails with the provided view helpers or Sprockets directives. +RailsExternalAssets will also hook into the `assets:precompile` Rake command and run the shell script defined by the `build_script` config. It will also hook into the `assets:clobber` Rake command and remove all the files in the directory specified by your `base_path` config (where your assets are built). + ### View Helpers #### JavaScript You can include a JavaScript file with `external_asset_js`. Note that the name of the file MUST include the file extension and the file name is the key in the asset manifest JSON file. @@ -127,20 +129,26 @@ { mime_type: 'application/javascript', comments: ['//', ['/*', '*/']] }, { mime_type: 'application/css', comments: ['//', ['/*', '*/']] } ] ``` +**build_script** + +This is the shell script that will be run prior to `assets:precompile` in Rails or with the `rake assets:build_external_assets` command. This should be the script that builds your assets (eg: `npm run build`). + +Note that in a Rails environment, `assets:clobber` will also remove all the files in your `base_path` directory (where your assets are built). + +> Defaults to `echo "You did not define a build script"` + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/jdlehman/rails_external_assets. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. - ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). -