sprockets-illusionist 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +105 -5
- data/lib/sprockets_illusionist/illusionist_template.rb +8 -2
- data/lib/sprockets_illusionist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7a3eee8fde5607db4866c3f897201132f48b1ce
|
4
|
+
data.tar.gz: a5986dc33e817201819451dfd0a8e0072dba1202
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13d421ac1f0fbe271daa87fb7d87f275f47017303768aea1fb883d11664449b3f94069cda1c4af83b343a8d77951ed674d12a30c891c7443e7c99bc9c5d72567
|
7
|
+
data.tar.gz: 04bfdfdf542891614d96a14a9803d782de23b2b4a3c6297379c7742c6ebe94d059c27eb77516b21151aa2b57afbe8891b7d68192e926f2e3f9b7763bf058c4bb
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# sprockets-illusionist
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/sprockets-illusionist.png)](http://badge.fury.io/rb/sprockets-illusionist) [![Code Climate](https://codeclimate.com/github/mirego/sprockets-illusionist.png)](https://codeclimate.com/github/mirego/sprockets-illusionist)
|
4
|
+
|
3
5
|
`sprockets-illusionist` makes it possible to transpile your ES6 files into ES5 using the [Illusionist node module](https://github.com/mirego/illusionist) and Sprockets.
|
4
6
|
|
7
|
+
**This entire guide assumes that you have [node](http://nodejs.org) and [npm](http://npmjs.org) already installed on your local machine.**
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
First, you will need the [Illusionist](https://github.com/mirego/illusionist) node package:
|
@@ -10,7 +14,7 @@ First, you will need the [Illusionist](https://github.com/mirego/illusionist) no
|
|
10
14
|
$ npm install -g illusionist
|
11
15
|
```
|
12
16
|
|
13
|
-
Add this line to your application’s Gemfile
|
17
|
+
Add this line to your application’s `Gemfile`:
|
14
18
|
|
15
19
|
```ruby
|
16
20
|
gem 'sprockets-illusionist'
|
@@ -24,15 +28,35 @@ $ bundle
|
|
24
28
|
|
25
29
|
## Usage
|
26
30
|
|
27
|
-
###
|
31
|
+
### Options
|
32
|
+
|
33
|
+
- `module_type`
|
34
|
+
|
35
|
+
The module type you want to use.
|
36
|
+
|
37
|
+
Available options: `amd`, `cjs` and `globals`
|
38
|
+
|
39
|
+
Default: `amd`
|
40
|
+
|
41
|
+
- `base_path` (only applies to AMD modules)
|
42
|
+
|
43
|
+
The `base_path` setting is used to name modules. Module names are relative paths to `base_path`, if you don’t set it, only the file name is used.
|
44
|
+
|
45
|
+
- `node_path`
|
46
|
+
|
47
|
+
The path to the node executable.
|
28
48
|
|
29
|
-
|
49
|
+
- `illusionist_path`
|
30
50
|
|
31
|
-
|
51
|
+
The path to the `illusionist` executable.
|
52
|
+
|
53
|
+
|
54
|
+
### Integrating with Rails
|
32
55
|
|
33
56
|
Create an initializer:
|
34
57
|
|
35
58
|
```ruby
|
59
|
+
# sprockets_illusionist.rb
|
36
60
|
SprocketsIllusionist::Config.configure do |config|
|
37
61
|
config.base_path = Rails.root.join('app', 'assets', 'javascripts')
|
38
62
|
|
@@ -58,6 +82,82 @@ controllers/foo_controller
|
|
58
82
|
|
59
83
|
With `sprockets-illusionist` just write your JavaScript files with the extension `.js.es6` and everything will be transpiled for you.
|
60
84
|
|
85
|
+
## Deploying on Heroku
|
86
|
+
|
87
|
+
**This guide assumes that you’re using environment variables which are available in Heroku Labs**
|
88
|
+
|
89
|
+
You can enable this feature by doing:
|
90
|
+
|
91
|
+
```bash
|
92
|
+
$ heroku labs:enable user-env-compile
|
93
|
+
```
|
94
|
+
|
95
|
+
Let’s get started!
|
96
|
+
|
97
|
+
1. You will need to use [heroku-buildpack-multi](https://github.com/ddollar/heroku-buildpack-multi) to install node and Ruby.
|
98
|
+
|
99
|
+
Tell Heroku to use the right buildpack:
|
100
|
+
|
101
|
+
```bash
|
102
|
+
$ heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
|
103
|
+
```
|
104
|
+
|
105
|
+
Create a `.buildpacks` file with the following content:
|
106
|
+
|
107
|
+
```
|
108
|
+
https://github.com/heroku/heroku-buildpack-nodejs.git
|
109
|
+
https://github.com/heroku/heroku-buildpack-ruby.git
|
110
|
+
```
|
111
|
+
|
112
|
+
2. You will need to include `illusionist` as a dependency of your project.
|
113
|
+
|
114
|
+
Create a `package.json` file with the following content:
|
115
|
+
|
116
|
+
```json
|
117
|
+
{
|
118
|
+
"name": "Your-Project",
|
119
|
+
"version": "0.0.1",
|
120
|
+
"dependencies": {
|
121
|
+
"illusionist": "~<insert latest version>"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
```
|
125
|
+
|
126
|
+
Install the dependencies on your local machine for development:
|
127
|
+
|
128
|
+
```bash
|
129
|
+
$ npm install
|
130
|
+
```
|
131
|
+
|
132
|
+
**Note that `heroku-buildpack-nodejs` does that for you at deploy time.**
|
133
|
+
|
134
|
+
3. You will need to link to the local installation of `illusionist` and node to get the latest version.
|
135
|
+
|
136
|
+
Your initializer should look like this:
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
SprocketsIllusionist::Config.configure do |config|
|
140
|
+
config.node_path = ENV['NODE_BIN_PATH']
|
141
|
+
config.illusionist_path = ENV['ILLUSIONIST_BIN_PATH']
|
142
|
+
config.base_path = Rails.root.join('app', 'assets', 'javascripts')
|
143
|
+
config.module_type = 'amd'
|
144
|
+
end
|
145
|
+
```
|
146
|
+
|
147
|
+
Then in `.env` on your local machine:
|
148
|
+
|
149
|
+
```
|
150
|
+
NODE_BIN_PATH=node
|
151
|
+
ILLUSIONIST_BIN_PATH=./node_modules/.bin/illusionist
|
152
|
+
```
|
153
|
+
|
154
|
+
Finally, set these environment variables on Heroku:
|
155
|
+
|
156
|
+
```bash
|
157
|
+
$ heroku config:set NODE_BIN_PATH=./vendor/node/bin/node
|
158
|
+
$ heroku config:set ILLUSIONIST_BIN_PATH=./node_modules/.bin/illusionist
|
159
|
+
```
|
160
|
+
|
61
161
|
## License
|
62
162
|
|
63
163
|
`sprockets-illusionist` is © 2014 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause).
|
@@ -65,6 +165,6 @@ See the [`LICENSE.md`](https://github.com/mirego/sprockets-illusionist/blob/mast
|
|
65
165
|
|
66
166
|
## About Mirego
|
67
167
|
|
68
|
-
[Mirego](http://mirego.com) is a team of passionate people who believe that work is a place where you can innovate and have fun. We
|
168
|
+
[Mirego](http://mirego.com) is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of [talented people](http://life.mirego.com) who imagine and build beautiful Web and mobile applications. We come together to share ideas and [change the world](http://mirego.org).
|
69
169
|
|
70
170
|
We also [love open-source software](http://open.mirego.com) and we try to give back to the community as much as we can.
|
@@ -10,8 +10,8 @@ module SprocketsIllusionist
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def evaluate(scope, locals, &block)
|
13
|
-
stdout,
|
14
|
-
stdout
|
13
|
+
stdout, stderr, _status = Open3.capture3("#{node_path} #{illusionist_path} #{option_string_from_config}", stdin_data: data)
|
14
|
+
stderr.empty? ? stdout : render_error(stderr)
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -52,5 +52,11 @@ module SprocketsIllusionist
|
|
52
52
|
|
53
53
|
options.join(' ')
|
54
54
|
end
|
55
|
+
|
56
|
+
def render_error(error)
|
57
|
+
error = error.gsub('"', '\"').gsub("\n", "\\n")
|
58
|
+
"// The file could not be compiled into JavaScript
|
59
|
+
document.getElementsByTagName('body')[0].innerHTML = \"<pre>#{error}</pre>\";"
|
60
|
+
end
|
55
61
|
end
|
56
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-illusionist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Demers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|