rails_external_assets 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 401fb50bb26e74bd9809f5ae1ae36b25b3bee376
|
4
|
+
data.tar.gz: 5358ed54efd266a62a4dab5c34d0d420e579b750
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5235105c1e0824f8d66d818869ef4a7d79089da4424c7b4cb0e983d837ce47f4d0d6bf69fd16f13c2aea19c4eb2652ead91a08685ffe4aae4cf77644ed546f28
|
7
|
+
data.tar.gz: 973a6cb4201c7d2889d637fbfc6ff850bbb4414e19f3f8b652e486c33f1270dbe309fe64422e372db7a4a20a0fa459249f0be5953825de47c2c80bd9d142899f
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# RailsExternalAssets
|
5
5
|
|
6
|
-
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:
|
6
|
+
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:
|
7
7
|
|
8
8
|
```json
|
9
9
|
{
|
@@ -13,7 +13,7 @@ RailsExternalAssets allows you to use the frontend build tool of your choice ([w
|
|
13
13
|
}
|
14
14
|
```
|
15
15
|
|
16
|
-
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.
|
16
|
+
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.
|
17
17
|
|
18
18
|
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.
|
19
19
|
|
@@ -39,6 +39,8 @@ Or install it yourself as:
|
|
39
39
|
|
40
40
|
You can include your external assets in Rails with the provided view helpers or Sprockets directives.
|
41
41
|
|
42
|
+
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).
|
43
|
+
|
42
44
|
### View Helpers
|
43
45
|
|
44
46
|
#### JavaScript
|
@@ -129,6 +131,14 @@ This is an array to configure the use of the `external_assets` Sprockets directi
|
|
129
131
|
]
|
130
132
|
```
|
131
133
|
|
134
|
+
**build_script**
|
135
|
+
|
136
|
+
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`).
|
137
|
+
|
138
|
+
Note that in a Rails environment, `assets:clobber` will also remove all the files in your `base_path` directory (where your assets are built).
|
139
|
+
|
140
|
+
> Defaults to `echo "You did not define a build script"`
|
141
|
+
|
132
142
|
## Development
|
133
143
|
|
134
144
|
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.
|
@@ -139,8 +149,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
139
149
|
|
140
150
|
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.
|
141
151
|
|
142
|
-
|
143
152
|
## License
|
144
153
|
|
145
154
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
146
|
-
|
@@ -18,7 +18,8 @@ module RailsExternalAssets
|
|
18
18
|
class Configuration
|
19
19
|
attr_accessor :base_path,
|
20
20
|
:manifest_file,
|
21
|
-
:sprockets_directives
|
21
|
+
:sprockets_directives,
|
22
|
+
:build_script
|
22
23
|
|
23
24
|
def initialize
|
24
25
|
# base path should be off Rails public/
|
@@ -28,6 +29,7 @@ module RailsExternalAssets
|
|
28
29
|
{ mime_type: 'application/javascript', comments: ['//', ['/*', '*/']] },
|
29
30
|
{ mime_type: 'application/css', comments: ['//', ['/*', '*/']] }
|
30
31
|
]
|
32
|
+
@build_script = 'echo "You did not define a build script"'
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# based on https://www.tomdooner.com/2014/06/29/webpack.html
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
Rake::Task['assets:precompile'].enhance(['assets:compile_environment'])
|
5
|
+
|
6
|
+
namespace :assets do
|
7
|
+
# set prerequisites for the assets:precompile task
|
8
|
+
task :compile_environment => :build_external_assets do
|
9
|
+
Rake::Task['assets:environment'].invoke
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Build external assets'
|
13
|
+
task :build_external_assets do
|
14
|
+
sh "NODE_ENV=#{Rails.env} #{RailsExternalAssets.config.build_script}"
|
15
|
+
end
|
16
|
+
|
17
|
+
task :clobber do
|
18
|
+
rm_rf File.join('public', RailsExternalAssets.config.base_path)
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_external_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Lehman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/rails_external_assets/rails/view_helpers.rb
|
80
80
|
- lib/rails_external_assets/sprockets.rb
|
81
81
|
- lib/rails_external_assets/sprockets/directive_processor.rb
|
82
|
+
- lib/rails_external_assets/tasks/assets.rake
|
82
83
|
- lib/rails_external_assets/version.rb
|
83
84
|
- rails_external_assets.gemspec
|
84
85
|
homepage: http://github.com/jdlehman/rails_external_assets
|