ember-cli-rails 0.5.8 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +180 -261
- data/app/controller/ember_cli/ember_controller.rb +5 -2
- data/app/helpers/ember_rails_helper.rb +15 -40
- data/app/views/ember_cli/ember/index.html.erb +1 -1
- data/lib/ember-cli-rails.rb +8 -28
- data/lib/ember_cli/app.rb +23 -29
- data/lib/ember_cli/asset_map.rb +64 -0
- data/lib/ember_cli/assets.rb +29 -44
- data/lib/ember_cli/command.rb +18 -10
- data/lib/ember_cli/configuration.rb +4 -37
- data/lib/ember_cli/directory_asset_map.rb +30 -0
- data/lib/ember_cli/engine.rb +0 -12
- data/lib/ember_cli/{constraint.rb → html_constraint.rb} +1 -1
- data/lib/ember_cli/path_set.rb +17 -9
- data/lib/ember_cli/route_helpers.rb +6 -2
- data/lib/ember_cli/shell.rb +6 -2
- data/lib/ember_cli/version.rb +1 -1
- data/lib/generators/{ember-cli → ember}/heroku/USAGE +1 -1
- data/lib/generators/{ember-cli → ember}/heroku/heroku_generator.rb +1 -11
- data/lib/generators/{ember-cli → ember}/heroku/templates/bin_heroku_install.erb +0 -0
- data/lib/generators/{ember-cli → ember}/heroku/templates/package.json.erb +0 -0
- data/lib/generators/ember/init/USAGE +8 -0
- data/lib/generators/{ember-cli → ember}/init/init_generator.rb +1 -1
- data/lib/generators/{ember-cli → ember}/init/templates/initializer.rb +0 -0
- metadata +14 -43
- data/lib/ember_cli/controller_extension.rb +0 -19
- data/lib/ember_cli/missing_manifest.rb +0 -11
- data/lib/ember_cli/sprockets.rb +0 -82
- data/lib/generators/ember-cli/init/USAGE +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36210f5c5119e4b769cec1174106772deb7aaea
|
4
|
+
data.tar.gz: 13161690fc11f87a3ec9786aa3a312eef18a5975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0c12d193f95eecb0a39002e47504be22a688d44c539018fd9a4328dfe4501490d652e17619254f2ffc2189562d547aa863888e1bc5a1bde56140e674febba26
|
7
|
+
data.tar.gz: 1eb93dd62ab7551dcf556c759aa50ce33d1d17f851bee689fb2826dc0ab168c3f47137da0edc52597dad890054f5ba767f3368ec022242d5040898e49edf6e36
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
master
|
2
2
|
------
|
3
3
|
|
4
|
+
0.6.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
* Use system-level `tee` to pipe `STDOUT` to both `STDOUT` and the logs. [#351]
|
8
|
+
* Invoke `EmberCli[ember_app].build` from helpers to ensure everything is built
|
9
|
+
before serving. [#347]
|
10
|
+
* Remove dependency on `sprockets`. Serve generated files with `Rack::File`.
|
11
|
+
[#336]
|
12
|
+
* Rename generator namespace from `ember-cli` to `ember`. [#344]
|
13
|
+
* Ensure `Rails.root.join("log")` exists when writing to logs.
|
14
|
+
* Remove deprecated `include_ember_index_html` helper and deprecated
|
15
|
+
`build_timeout` and `enabled` configurations. [#334]
|
16
|
+
* Raise build errors for `render_ember_app` failures. [#325]
|
17
|
+
* Remove `before_{action,filter}` in favor of explicit `EmberCli.build(app)`
|
18
|
+
call. [#327]
|
19
|
+
|
20
|
+
[#351]: https://github.com/thoughtbot/ember-cli-rails/pull/351
|
21
|
+
[#347]: https://github.com/thoughtbot/ember-cli-rails/pull/347
|
22
|
+
[#336]: https://github.com/thoughtbot/ember-cli-rails/pull/336
|
23
|
+
[#344]: https://github.com/thoughtbot/ember-cli-rails/pull/344
|
24
|
+
[#334]: https://github.com/thoughtbot/ember-cli-rails/pull/334
|
25
|
+
[#327]: https://github.com/thoughtbot/ember-cli-rails/pull/327
|
26
|
+
[#325]: https://github.com/thoughtbot/ember-cli-rails/pull/325
|
27
|
+
|
4
28
|
0.5.8
|
5
29
|
-----
|
6
30
|
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ EmberCLI-Rails is designed to give you the best of both worlds:
|
|
11
11
|
applications and your API from a single domain
|
12
12
|
* Write truly end-to-end integration tests, exercising your application's entire
|
13
13
|
stack through JavaScript-enabled Capybara tests
|
14
|
-
* Deploy your entire suite of applications with a single `git push`
|
14
|
+
* Deploy your entire suite of applications to Heroku with a single `git push`
|
15
15
|
|
16
16
|
**EmberCLI-Rails Supports EmberCLI 1.13.x and later.**
|
17
17
|
|
@@ -34,7 +34,7 @@ $ bundle install
|
|
34
34
|
First, generate the gem's initializer:
|
35
35
|
|
36
36
|
```bash
|
37
|
-
$ rails generate ember
|
37
|
+
$ rails generate ember:init
|
38
38
|
```
|
39
39
|
|
40
40
|
This will create the following initializer:
|
@@ -85,19 +85,19 @@ Next, install the [ember-cli-rails-addon][addon]:
|
|
85
85
|
|
86
86
|
```bash
|
87
87
|
$ cd path/to/frontend
|
88
|
-
$
|
88
|
+
$ ember install ember-cli-rails-addon
|
89
89
|
```
|
90
90
|
|
91
91
|
Be sure that the addon's [`MAJOR` and `MINOR` version][semver] matches the gem's
|
92
92
|
`MAJOR` and `MINOR` versions.
|
93
93
|
|
94
|
-
For instance, if you're using the `0.
|
95
|
-
`~> 0.
|
94
|
+
For instance, if you're using the `0.6.x` version of the gem, specify
|
95
|
+
`~> 0.6.0` in your Ember app's `package.json`:
|
96
96
|
|
97
97
|
```json
|
98
98
|
{
|
99
99
|
"devDependencies": {
|
100
|
-
"ember-cli-rails-addon": "~> 0.
|
100
|
+
"ember-cli-rails-addon": "~> 0.6.0"
|
101
101
|
}
|
102
102
|
}
|
103
103
|
```
|
@@ -127,47 +127,104 @@ In the above example, `params[:ember_app] == :frontend`.
|
|
127
127
|
* `controller` - Defaults to `"ember_cli/ember"`
|
128
128
|
* `action` - Defaults to `"index"`
|
129
129
|
|
130
|
-
|
131
|
-
route, and see your EmberCLI app!
|
130
|
+
Finally, install your Ember application's dependencies:
|
132
131
|
|
133
|
-
|
132
|
+
```bash
|
133
|
+
$ rake ember:install
|
134
|
+
```
|
134
135
|
|
135
|
-
|
136
|
-
|
137
|
-
application's `index.html` and injects the Rails-generated CSRF tags into the
|
138
|
-
`<head>`.
|
136
|
+
Boot your Rails application, navigate to `"/"`, and view your EmberCLI
|
137
|
+
application!
|
139
138
|
|
140
|
-
|
139
|
+
## Heroku
|
141
140
|
|
142
|
-
|
143
|
-
# config/routes
|
141
|
+
To configure your EmberCLI-Rails applications for Heroku:
|
144
142
|
|
145
|
-
|
146
|
-
|
147
|
-
|
143
|
+
1. Execute `rails generate ember:heroku`
|
144
|
+
1. [Add the NodeJS buildpack][buildpack] and configure NPM to include the
|
145
|
+
`bower` dependency's executable file.
|
146
|
+
|
147
|
+
```sh
|
148
|
+
$ heroku buildpacks:clear
|
149
|
+
$ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-nodejs
|
150
|
+
$ heroku buildpacks:add --index 2 https://github.com/heroku/heroku-buildpack-ruby
|
151
|
+
$ heroku config:set NPM_CONFIG_PRODUCTION=false
|
152
|
+
$ heroku config:unset SKIP_EMBER
|
148
153
|
```
|
149
154
|
|
150
|
-
|
151
|
-
|
155
|
+
You are ready to deploy:
|
156
|
+
|
157
|
+
```bash
|
158
|
+
$ git push heroku master
|
159
|
+
```
|
160
|
+
|
161
|
+
**NOTE** Run the generator each time you introduce additional EmberCLI
|
162
|
+
applications into the project.
|
163
|
+
|
164
|
+
[buildpack]: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack
|
165
|
+
|
166
|
+
## Overriding the defaults
|
167
|
+
|
168
|
+
By default, routes defined by `ember_app` will be rendered with the internal
|
169
|
+
`EmberCli::EmberController`.
|
170
|
+
|
171
|
+
### Overriding the view
|
172
|
+
|
173
|
+
The `EmberCli::EmberController` renders the Ember application's `index.html` and
|
174
|
+
injects the Rails-generated CSRF tags into the `<head>`.
|
175
|
+
|
176
|
+
To customize the view, create `app/views/ember_cli/ember/index.html.erb`:
|
152
177
|
|
153
178
|
```erb
|
154
|
-
|
155
|
-
|
179
|
+
<%= render_ember_app ember_app do |head| %>
|
180
|
+
<% head.append do %>
|
181
|
+
<%= csrf_meta_tags %>
|
182
|
+
<% end %>
|
183
|
+
<% end %>
|
156
184
|
```
|
157
185
|
|
158
|
-
|
159
|
-
|
186
|
+
The `ember_app` helper is available within the `EmberCli::EmberController`'s
|
187
|
+
view, and refers to the name of the current EmberCLI application.
|
188
|
+
|
189
|
+
To inject the EmberCLI generated `index.html`, use the `render_ember_app`
|
190
|
+
helper in your view:
|
160
191
|
|
161
192
|
```erb
|
162
193
|
<!-- app/views/application/index.html.erb -->
|
163
|
-
<%= render_ember_app :frontend do |head| %>
|
194
|
+
<%= render_ember_app :frontend do |head, body| %>
|
164
195
|
<% head.append do %>
|
165
196
|
<%= csrf_meta_tags %>
|
166
197
|
<% end %>
|
198
|
+
|
199
|
+
<% body.append do %>
|
200
|
+
<%= render partial: "my-analytics" %>
|
201
|
+
<% end %>
|
167
202
|
<% end %>
|
168
203
|
```
|
169
204
|
|
170
|
-
|
205
|
+
The `body` block argument and the corresponding call to `body.append` in the
|
206
|
+
example are both optional, and can be omitted.
|
207
|
+
|
208
|
+
### Overriding the controller
|
209
|
+
|
210
|
+
To override this behavior, you can specify [any of Rails' routing options]
|
211
|
+
[route-options].
|
212
|
+
|
213
|
+
[route-options]: http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Base.html#method-i-match
|
214
|
+
|
215
|
+
For the sake of this example, override the `controller` and `action` options:
|
216
|
+
|
217
|
+
```rb
|
218
|
+
# config/routes
|
219
|
+
|
220
|
+
Rails.application.routes.draw do
|
221
|
+
mount_ember_app :frontend, to: "/", controller: "application", action: "index"
|
222
|
+
end
|
223
|
+
```
|
224
|
+
|
225
|
+
When serving the EmberCLI generated `index.html` with the `render_ember_app`
|
226
|
+
helper, make sure the controller's `layout` is disabled, as EmberCLI generates a
|
227
|
+
fully-formed HTML document:
|
171
228
|
|
172
229
|
```rb
|
173
230
|
# app/controllers/application.rb
|
@@ -178,89 +235,129 @@ class ApplicationController < ActionController::Base
|
|
178
235
|
end
|
179
236
|
```
|
180
237
|
|
181
|
-
|
238
|
+
#### Rendering the EmberCLI generated JS and CSS
|
182
239
|
|
183
|
-
|
184
|
-
|
185
|
-
descendant of `ActionController::Base`][#320].
|
240
|
+
Rendering EmberCLI applications with `render_ember_app` is the recommended,
|
241
|
+
actively supported method of serving EmberCLI applications.
|
186
242
|
|
187
|
-
|
188
|
-
|
243
|
+
However, for the sake of backwards compatibility, `ember-cli-rails` supports
|
244
|
+
injecting the EmberCLI-generated assets into an existing Rails layout.
|
189
245
|
|
190
|
-
|
246
|
+
Following the example above, configure the mounted EmberCLI application to be
|
247
|
+
served by a custom controller (`ApplicationController`, in this case).
|
191
248
|
|
192
|
-
In
|
193
|
-
`<script>` and `<link>` tags into your Rails generated views:
|
249
|
+
In the corresponding view, use the asset helpers:
|
194
250
|
|
195
251
|
```erb
|
196
|
-
<!-- app/views/application/index.html.erb -->
|
197
252
|
<%= include_ember_script_tags :frontend %>
|
198
253
|
<%= include_ember_stylesheet_tags :frontend %>
|
199
254
|
```
|
200
255
|
|
201
|
-
|
256
|
+
### Mounting the Ember applications
|
202
257
|
|
203
|
-
|
258
|
+
Rendering Ember applications from routes other than `/` requires additional
|
259
|
+
configuration.
|
204
260
|
|
205
|
-
|
261
|
+
Consider a scenario where you had Ember applications named `frontend` and
|
262
|
+
`admin_panel`, served from `/` and `/admin_panel` respectively.
|
206
263
|
|
207
|
-
|
208
|
-
referenced with the view helper independently. You'd accomplish this like so:
|
264
|
+
First, specify the Ember applications in the initializer:
|
209
265
|
|
210
266
|
```ruby
|
211
|
-
|
267
|
+
EmberCli.configure do |c|
|
212
268
|
c.app :frontend
|
213
|
-
c.app :admin_panel, path: "/
|
269
|
+
c.app :admin_panel, path: "path/to/admin_ember_app"
|
214
270
|
end
|
215
271
|
```
|
216
272
|
|
217
|
-
|
218
|
-
to avoid an Ember `UnrecognizedURLError`.
|
219
|
-
|
220
|
-
For instance, if you had Ember applications named `:frontend` and
|
221
|
-
`:admin_panel` and you wanted to serve them at `/frontend` and `/admin_panel`,
|
222
|
-
you would set up the following Rails routes:
|
273
|
+
Next, mount the applications alongside the rest of Rails' routes:
|
223
274
|
|
224
275
|
```rb
|
225
276
|
# /config/routes.rb
|
226
277
|
Rails.application.routes.draw do
|
227
|
-
mount_ember_app :frontend, to: "/
|
278
|
+
mount_ember_app :frontend, to: "/"
|
228
279
|
mount_ember_app :admin_panel, to: "/admin_panel"
|
229
280
|
end
|
230
281
|
```
|
231
282
|
|
232
|
-
|
283
|
+
Then set each Ember application's `baseURL` to the mount point:
|
233
284
|
|
234
285
|
```javascript
|
235
|
-
//
|
286
|
+
// frontend/config/environment.js
|
236
287
|
|
237
288
|
module.exports = function(environment) {
|
238
289
|
var ENV = {
|
239
290
|
modulePrefix: 'frontend',
|
240
291
|
environment: environment,
|
241
|
-
baseURL: '/
|
242
|
-
...
|
292
|
+
baseURL: '/',
|
293
|
+
// ...
|
243
294
|
}
|
244
|
-
}
|
295
|
+
};
|
245
296
|
|
246
|
-
//
|
297
|
+
// path/to/admin_ember_app/config/environment.js
|
247
298
|
|
248
299
|
module.exports = function(environment) {
|
249
300
|
var ENV = {
|
250
301
|
modulePrefix: 'admin_panel',
|
251
302
|
environment: environment,
|
252
303
|
baseURL: '/admin_panel', // originally '/'
|
253
|
-
...
|
304
|
+
// ...
|
254
305
|
}
|
255
|
-
}
|
306
|
+
};
|
307
|
+
```
|
308
|
+
|
309
|
+
Finally, configure EmberCLI's fingerprinting to prepend the mount point to the
|
310
|
+
application's assets:
|
311
|
+
|
312
|
+
```js
|
313
|
+
// frontend/ember-cli-build.js
|
314
|
+
|
315
|
+
module.exports = function(defaults) {
|
316
|
+
var app = new EmberApp(defaults, {
|
317
|
+
fingerprint: {
|
318
|
+
// matches the `/` mount point
|
319
|
+
prepend: 'https://cdn.example.com/',
|
320
|
+
}
|
321
|
+
});
|
322
|
+
};
|
323
|
+
|
324
|
+
|
325
|
+
// path/to/admin_ember_app/ember-cli-build.js
|
326
|
+
|
327
|
+
module.exports = function(defaults) {
|
328
|
+
var app = new EmberApp(defaults, {
|
329
|
+
fingerprint: {
|
330
|
+
// matches the `/admin_panel` mount point
|
331
|
+
prepend: 'https://cdn.example.com/admin_panel/',
|
332
|
+
}
|
333
|
+
});
|
334
|
+
};
|
335
|
+
```
|
336
|
+
|
337
|
+
When injecting the EmberCLI-generated assets with the `include_ember_script_tags`
|
338
|
+
and `include_ember_stylesheet_tags` helpers to a path other than `"/"`, a
|
339
|
+
`<base>` tag must also be injected with a corresponding `href` value:
|
340
|
+
|
341
|
+
```erb
|
342
|
+
<%= include_ember_script_tags :frontend %>
|
343
|
+
<%= include_ember_stylesheet_tags :frontend %>
|
344
|
+
|
345
|
+
<base href="/admin_panel/">
|
346
|
+
<%= include_ember_script_tags :admin_panel %>
|
347
|
+
<%= include_ember_stylesheet_tags :admin_panel %>
|
256
348
|
```
|
257
349
|
|
258
350
|
## CSRF Tokens
|
259
351
|
|
260
|
-
Your Rails controllers, by default,
|
261
|
-
|
352
|
+
Your Rails controllers, by default, expect a valid authenticity token to
|
353
|
+
be submitted along with non-`GET` requests.
|
354
|
+
|
355
|
+
Without the authenticity token, requests will respond with
|
356
|
+
`422 Unprocessable Entity` errors (specifically
|
357
|
+
`ActionController::InvalidAuthenticityToken`).
|
262
358
|
|
263
|
-
|
359
|
+
To add the necessary tokens to requests, inject the `csrf_meta_tags` into
|
360
|
+
the template:
|
264
361
|
|
265
362
|
```erb
|
266
363
|
<!-- app/views/application/index.html.erb -->
|
@@ -271,21 +368,32 @@ In order to add that token to your requests, you need to add into your template:
|
|
271
368
|
<% end %>
|
272
369
|
```
|
273
370
|
|
274
|
-
The default `EmberCli::EmberController` and
|
275
|
-
|
371
|
+
The default `EmberCli::EmberController` and the default view handle behave like
|
372
|
+
this by default.
|
276
373
|
|
277
|
-
|
278
|
-
|
374
|
+
If an Ember application is mounted with another controller, it should append
|
375
|
+
the CSRF tags to its view's `<head>`.
|
279
376
|
|
280
|
-
|
281
|
-
|
282
|
-
Rails.
|
377
|
+
[ember-cli-rails-addon][addon] configures your Ember application to make HTTP
|
378
|
+
requests with the injected CSRF tokens in the `X-CSRF-TOKEN` header.
|
283
379
|
|
284
380
|
### Integrating with Rake
|
285
381
|
|
286
|
-
EmberCLI Rails exposes
|
382
|
+
EmberCLI Rails exposes several useful rake tasks.
|
383
|
+
|
384
|
+
**`ember:install`**
|
385
|
+
|
386
|
+
Install the Ember applications' dependencies.
|
387
|
+
|
388
|
+
**`ember:compile`**
|
389
|
+
|
390
|
+
Compile the Ember applications.
|
391
|
+
|
392
|
+
**`ember:test`**
|
287
393
|
|
288
|
-
|
394
|
+
Execute Ember's test suite.
|
395
|
+
|
396
|
+
If you're using Rake to run the test suite, make sure to configure your test
|
289
397
|
task to depend on `ember:test`.
|
290
398
|
|
291
399
|
For example, to configure a bare `rake` command to run both RSpec and Ember test
|
@@ -307,163 +415,6 @@ EmberCLI runners to clobber each others' work][#94].
|
|
307
415
|
[Unicorn]: https://rubygems.org/gems/unicorn
|
308
416
|
[#94]: https://github.com/thoughtbot/ember-cli-rails/issues/94#issuecomment-77627453
|
309
417
|
|
310
|
-
## Enabling LiveReload
|
311
|
-
|
312
|
-
In order to get LiveReload up and running with Ember CLI Rails, you can install
|
313
|
-
[guard](https://github.com/guard/guard) and
|
314
|
-
[guard-livereload](https://github.com/guard/guard-livereload) gems, run `guard
|
315
|
-
init` and then add the following to your `Guardfile`.
|
316
|
-
|
317
|
-
```ruby
|
318
|
-
guard "livereload" do
|
319
|
-
# ...
|
320
|
-
watch %r{your-appname/app/\w+/.+\.(js|hbs|html|css|<other-extensions>)}
|
321
|
-
# ...
|
322
|
-
end
|
323
|
-
```
|
324
|
-
|
325
|
-
This tells Guard to watch your Ember CLI app for any changes to the JavaScript,
|
326
|
-
Handlebars, HTML, or CSS files within `app` path. Take note that other
|
327
|
-
extensions can be added to the line (such as `coffee` for CoffeeScript) to
|
328
|
-
watch them for changes as well.
|
329
|
-
|
330
|
-
*NOTE:* Ember CLI creates symlinks in `your-appname/tmp` directory, which cannot
|
331
|
-
be handled properly by Guard. This might lead to performance issues on some
|
332
|
-
platforms (most notably on OSX), as well as warnings being printed by latest
|
333
|
-
versions of Guard. As a work-around, one might use
|
334
|
-
[`directories`](https://github.com/guard/guard/wiki/Guardfile-DSL---Configuring-Guard#directories)
|
335
|
-
option, explicitly specifying directories to watch, e.g. adding the following
|
336
|
-
to the `Guardfile`.
|
337
|
-
|
338
|
-
```ruby
|
339
|
-
# also add directories that need to be watched by other guard plugins
|
340
|
-
directories %w[app config lib spec your-appname/app]
|
341
|
-
```
|
342
|
-
|
343
|
-
## Heroku
|
344
|
-
|
345
|
-
To configure your Ember CLI Rails app to be ready to deploy on Heroku:
|
346
|
-
|
347
|
-
1. Run `rails g ember-cli:heroku` generator
|
348
|
-
1. [Add the NodeJS buildpack][buildpack] and configure NPM to include the
|
349
|
-
`bower` dependency's executable file.
|
350
|
-
|
351
|
-
```sh
|
352
|
-
$ heroku buildpacks:clear
|
353
|
-
$ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-nodejs
|
354
|
-
$ heroku buildpacks:add --index 2 https://github.com/heroku/heroku-buildpack-ruby
|
355
|
-
$ heroku config:set NPM_CONFIG_PRODUCTION=false
|
356
|
-
$ heroku config:unset SKIP_EMBER
|
357
|
-
```
|
358
|
-
|
359
|
-
You should be ready to deploy.
|
360
|
-
|
361
|
-
The generator will disable Rails' JavaScript compression by declaring:
|
362
|
-
|
363
|
-
```rb
|
364
|
-
config.assets.js_compressor = nil
|
365
|
-
```
|
366
|
-
|
367
|
-
This is recommended, but might not work for projects that have both Asset
|
368
|
-
Pipeline and EmberCLI generated JavaScript.
|
369
|
-
|
370
|
-
To reverse this change, reconfigure Sprockets to use the `uglifier` gem:
|
371
|
-
|
372
|
-
```rb
|
373
|
-
config.assets.js_compressor = :uglifier
|
374
|
-
```
|
375
|
-
|
376
|
-
**NOTE** Run the generator each time you introduce additional EmberCLI
|
377
|
-
applications into the project.
|
378
|
-
|
379
|
-
[buildpack]: https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app#adding-a-buildpack
|
380
|
-
|
381
|
-
## Capistrano
|
382
|
-
|
383
|
-
To deploy an EmberCLI-Rails application with Capistrano, make sure your
|
384
|
-
EmberCLI app's `package.json` file includes the `bower` package as a development
|
385
|
-
dependency:
|
386
|
-
|
387
|
-
```json
|
388
|
-
{
|
389
|
-
"devDependencies": {
|
390
|
-
"bower": "*"
|
391
|
-
}
|
392
|
-
}
|
393
|
-
```
|
394
|
-
|
395
|
-
## Experiencing Slow Build/Deploy Times?
|
396
|
-
Remove `ember-cli-uglify` from your `package.json` file, and run
|
397
|
-
`npm remove ember-cli-uglify`. This will improve your build/deploy
|
398
|
-
time by about 10 minutes.
|
399
|
-
|
400
|
-
The reason build/deploy times were slow is because ember uglified the JS and
|
401
|
-
then added the files to the asset pipeline. Rails would then try and uglify
|
402
|
-
the JS again, and this would be considerably slower than normal.
|
403
|
-
|
404
|
-
See also the note on [Javascript minification](#javascript-minification)
|
405
|
-
|
406
|
-
## JavaScript minification
|
407
|
-
|
408
|
-
When pre-compiling assets in production, you will want to
|
409
|
-
ensure that you are not minifying your JavaScript twice: once with EmberCLI's
|
410
|
-
build tools and once with the Asset Pipeline. Repeated minification is wasteful
|
411
|
-
and can increase deployment times exponentially.
|
412
|
-
|
413
|
-
You can either disable minification in your EmberCLI application's
|
414
|
-
`ember-cli-build.js`:
|
415
|
-
|
416
|
-
```javascript
|
417
|
-
/* global require, module */
|
418
|
-
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
419
|
-
|
420
|
-
module.exports = function(defaults) {
|
421
|
-
var app = new EmberApp({
|
422
|
-
minifyJS: false,
|
423
|
-
});
|
424
|
-
|
425
|
-
// ...
|
426
|
-
};
|
427
|
-
```
|
428
|
-
|
429
|
-
or in your Rails application's `config/environments/production.rb`:
|
430
|
-
|
431
|
-
```ruby
|
432
|
-
Rails.application.configure do
|
433
|
-
config.assets.js_compressor = nil
|
434
|
-
end
|
435
|
-
```
|
436
|
-
|
437
|
-
## Additional Information
|
438
|
-
|
439
|
-
When running in the development environment, Ember CLI Rails runs `ember build`
|
440
|
-
with the `--output-path` and `--watch` flags on. The `--watch` flag tells
|
441
|
-
Ember CLI to watch for file system events and rebuild when an Ember CLI file is
|
442
|
-
changed. The `--output-path` flag specifies where the distribution files will
|
443
|
-
be put. Ember CLI Rails does some fancy stuff to get it into your asset path
|
444
|
-
without polluting your git history. Note that for this to work, you must have
|
445
|
-
`config.consider_all_requests_local = true` set in
|
446
|
-
`config/environments/development.rb`, otherwise the middleware responsible for
|
447
|
-
building Ember CLI will not be enabled.
|
448
|
-
|
449
|
-
Alternatively, if you want to override the default behavior in any given Rails
|
450
|
-
environment, you can manually set the `config.use_ember_middleware` and
|
451
|
-
`config.use_ember_live_recompilation` flags in the environment-specific config
|
452
|
-
file.
|
453
|
-
|
454
|
-
### `ASSET_HOST`
|
455
|
-
|
456
|
-
Used by [the addon][addon] during fingerprinting.
|
457
|
-
|
458
|
-
When compiling an Ember app named `"frontend"` from within Rails,
|
459
|
-
the addon will prepend the generated asset paths with:
|
460
|
-
|
461
|
-
${ASSET_HOST}/assets/frontend/
|
462
|
-
|
463
|
-
### `CDN_HOST`
|
464
|
-
|
465
|
-
Behaves the same way as `ASSET_HOST`, acting as a fallback.
|
466
|
-
|
467
418
|
### `RAILS_ENV`
|
468
419
|
|
469
420
|
While being managed by EmberCLI Rails, EmberCLI process will have
|
@@ -490,47 +441,15 @@ if (environment === 'development') {
|
|
490
441
|
|
491
442
|
[ember-cli-mirage]: http://ember-cli-mirage.com/docs/latest/
|
492
443
|
|
493
|
-
### `SKIP_EMBER`
|
494
|
-
|
495
|
-
To disable asset compilation entirely, set an environment variable
|
496
|
-
`SKIP_EMBER=1`.
|
497
|
-
|
498
|
-
This can be useful when an application's frontend is developed locally with
|
499
|
-
EmberCLI-Rails, but deployed separately (for example, with
|
500
|
-
[ember-cli-deploy][ember-cli-deploy]).
|
501
|
-
|
502
|
-
[ember-cli-deploy]: https://github.com/ember-cli/ember-cli-deploy
|
503
|
-
|
504
|
-
#### Ember Dependencies
|
505
|
-
|
506
|
-
Ember has several dependencies. Some of these dependencies might already be
|
507
|
-
present in your asset list. For example jQuery is bundled in `jquery-rails` gem.
|
508
|
-
If you have the jQuery assets included on your page you may want to exclude them
|
509
|
-
from the Ember distribution. You can do so by setting the `exclude_ember_deps`
|
510
|
-
option like so:
|
511
|
-
|
512
|
-
```ruby
|
513
|
-
EmberCli.configure do |c|
|
514
|
-
c.app :frontend, exclude_ember_deps: "jquery"
|
515
|
-
c.app :admin_panel, exclude_ember_deps: ["jquery", "handlebars"]
|
516
|
-
end
|
517
|
-
```
|
518
|
-
|
519
|
-
jQuery and Handlebars are the main use cases for this flag.
|
520
|
-
|
521
444
|
## Ruby and Rails support
|
522
445
|
|
523
446
|
This project supports:
|
524
447
|
|
525
448
|
* Ruby versions `>= 2.1.0`
|
526
|
-
* Rails versions
|
527
|
-
|
528
|
-
[Rendering EmberCLI-generated assets through Sprockets](asset-helpers) is
|
529
|
-
**NOT** supported for Rails `3.2.x`.
|
449
|
+
* Rails versions `>=4.1.x`.
|
530
450
|
|
531
451
|
To learn more about supported versions and upgrades, read the [upgrading guide].
|
532
452
|
|
533
|
-
[asset-helpers]: #rendering-the-embercli-generated-js-and-css
|
534
453
|
[upgrading guide]: /UPGRADING.md
|
535
454
|
|
536
455
|
## Contributing
|