Skip to content

Commit

Permalink
Refine the installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Mar 27, 2016
1 parent c9ac43d commit 86c9dee
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,40 @@ Turbolinks works in all modern desktop and mobile browsers. It depends on the [H

Include [`dist/turbolinks.js`](dist/turbolinks.js) in your application’s JavaScript bundle.

### Installation Via Webpack and NPM
### Installation Using Ruby on Rails

#### Add turbolinks to package.json
`npm install --save turbolinks`
Your Ruby on Rails application can use the [`turbolinks` RubyGem](https://github.com/turbolinks/turbolinks-rails) to install Turbolinks. This gem contains a Rails engine which integrates seamlessly with the Rails asset pipeline.

#### Update your webpack.config.js
1. Add `turbolinks` as an entry point (`entry` section).
2. Include this line in your module.loaders section
```
module: {
loaders: [
{ test: require.resolve('turbolinks'), loader: 'imports?this=>window' },
```
1. Add the `turbolinks` gem, version 5, to your Gemfile: `gem 'turbolinks', '~> 5.0.0.beta'`
2. Run `bundle install`.
3. Add `//= require turbolinks` to your JavaScript manifest file (usually found at `app/assets/javascripts/application.js`).

This [pull request](https://github.com/shakacode/react-webpack-rails-tutorial/pull/259) demonstrates the conversion of a sample project from the ruby gem of turbolinks to the npm version. You can see this app, which uses webpack and Turbolinks via npm, live at http://www.reactrails.com.
The gem also provides server-side support for Turbolinks redirection.

### Rails Integration
### Installation Using Webpack

The Turbolinks gem is packaged as a Rails engine and integrates seamlessly with the Rails asset pipeline. To install:
Your application can use the [`turbolinks` npm package](https://www.npmjs.com/package/turbolinks) to install Turbolinks in a [Webpack](http://webpack.github.io/) asset bundle.

1. Add the `turbolinks` gem, version 5, to your Gemfile: `gem 'turbolinks', '~> 5.0.0.beta'`
2. Run `bundle install`.
3. Add `//= require turbolinks` to your JavaScript manifest file (usually found at `app/assets/javascripts/application.js`).
1. Add the `turbolinks` package to your application: `npm install --save turbolinks@beta`.
2. Add `turbolinks` to the `entry` section of webpack.config.js:

```js
entry: {
vendor: [ ...,
'turbolinks',
],
},
```

3. Set up Turbolinks in the `module.loaders` section of webpack.config.js:

```js
module: {
loaders: [ ...,
{ test: require.resolve('turbolinks'), loader: 'imports?this=>window' },
],
},
```

# Navigating with Turbolinks

Expand Down

0 comments on commit 86c9dee

Please sign in to comment.