webpack-rails 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec91481d23ce6db4247d25ca1bb730507b519ed4
4
- data.tar.gz: 18917f0f2d8b6b53b15a911285b5d569b0a7b13c
3
+ metadata.gz: 1dc23fea18ea8659819c53e4ca80b1c55fa3499d
4
+ data.tar.gz: 4bc774c2a80a9baa66f97423b265625668e05f8f
5
5
  SHA512:
6
- metadata.gz: e9e869c5128bce7dd9343b55d2ab921c942f42a129a767188b8d42c9c8b1bd33fe0c343f601c6d640828fee4f5027b72f104f13d3392e9536c06f3a9d2858cd4
7
- data.tar.gz: 8004a6c83ffc84f522023774befb8aa44f4dc10e69d36efd50bb1a1aa491c5155ef8f40e26f98a695e750899f43141fbbe9fdf22e27137bd94d9f99ea417270c
6
+ metadata.gz: caa38990e879cfbde46cea29e40893ac96f5a18a77c41991ad39a6be4b4c00b229abcfe42f0bd30b5daaa75bed7411f45dbf2b94b54b80c62585202b706a63e2
7
+ data.tar.gz: 23130dff97ca54a41ba451263c9a09a5e5eb31af61fbcd2ef06013dbe215c1ef51b0264bf6b8fc0fe2bf55fbac78d20bc57137321921758bb0861bf5a8b009e3
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # webpack-rails
1
+ [![Build Status](https://travis-ci.org/mipearson/webpack-rails.svg?branch=master)](https://travis-ci.org/mipearson/webpack-rails) [![Gem Version](https://badge.fury.io/rb/webpack-rails.svg)](http://badge.fury.io/rb/webpack-rails)
2
2
 
3
- [![Build Status](https://travis-ci.org/mipearson/webpack-rails.svg?branch=master)](https://travis-ci.org/mipearson/webpack-rails)
3
+ # webpack-rails
4
4
 
5
5
  **webpack-rails** gives you tools to integrate Webpack in to an existing Ruby on Rails application.
6
6
 
@@ -10,26 +10,42 @@ In development mode [webpack-dev-server](http://webpack.github.io/docs/webpack-d
10
10
 
11
11
  It was designed for use at [Marketplacer](http://www.marketplacer.com) to assist us in migrating our Javascript (and possibly our SCSS) off of Sprockets. It first saw production use in June 2015.
12
12
 
13
- As this is pre-1.0 software its API and configuration may change as we become more familiar with Webpack. This gem has been developed against Ruby 2.2 and Rails 4.2. Previous versions might work, but I haven't tested them. Assume Rails 3.2 and Ruby 1.9 as an absolute minimum.
13
+ Our examples show **webpack-rails** co-existing with sprockets (as that's how environment works), but sprockets is not used or required for development or production use of this gem.
14
14
 
15
- ## Getting Started
15
+ This gem has been tested against Rails 4.2 and Ruby 2.2. Earlier versions of Rails (>= 3.2) and Ruby (>= 1.9) may work, but we haven't tested them.
16
+
17
+ ## Using webpack-rails
16
18
 
17
19
  **We have a demo application: [webpack-rails-demo](https://github.com/mipearson/webpack-rails-demo)**
18
20
 
19
- Have a look at the files in the `examples` directory. Of note:
21
+ ### Installation
22
+
23
+ 1. Add `webpack-rails` to your gemfile
24
+ 1. Run `bundle install` to install the gem
25
+ 1. Run `bundle exec rails generate webpack_rails:install` to copy across example files
26
+ 1. Run `foreman start` to start `webpack-dev-server` and `rails server` at the same time
27
+ 1. Add the webpack entry point to your layout (see next section)
28
+ 1. Edit `webpack/application.js` and write some code
20
29
 
21
- * We use [foreman](https://github.com/ddollar/foreman) and a `Procfile` to run our rails server & the webpack dev server in development at the same time
22
- * The webpack and gem configuration must be in sync - look at our railtie for configuration options
23
- * We require that **stats-webpack-plugin** is loaded to automatically generate a production manifest & resolve paths during development
24
30
 
25
- To access webpacked assets from your views:
31
+ ### Adding the entry point to your Rails application
32
+
33
+ To add your webpacked javascript in to your app, add the following to the `<head>` section of your to your `layout.html.erb`:
26
34
 
27
35
  ```erb
28
- <%= javascript_include_tag *webpack_asset_paths("entry_point_name") %>
36
+ <%= javascript_include_tag *webpack_asset_paths("application") %>
29
37
  ```
30
38
 
31
39
  Take note of the splat (`*`): `webpack_asset_paths` returns an array, as one entry point can map to multiple paths, especially if hot reloading is enabled in Webpack.
32
40
 
41
+ ### How it works
42
+
43
+ Have a look at the files in the `examples` directory. Of note:
44
+
45
+ * We use [foreman](https://github.com/ddollar/foreman) and a `Procfile` to run our rails server & the webpack dev server in development at the same time
46
+ * The webpack and gem configuration must be in sync - look at our railtie for configuration options
47
+ * We require that **stats-webpack-plugin** is loaded to automatically generate a production manifest & resolve paths during development
48
+
33
49
  ### Configuration Defaults
34
50
 
35
51
  * Webpack configuration lives in `config/webpack.config.js`
@@ -51,10 +67,7 @@ If you're using `[chunkhash]` in your build asset filenames (which you should be
51
67
 
52
68
  ## TODO
53
69
 
54
- * Release gem
55
- * travisci & codeclimate & gem badges
56
70
  * Drive config via JSON, have webpack.config.js read same JSON?
57
- * Generators for webpack config, Gemfile, Procfile, package.json
58
71
  * Custom webpack-dev-server that exposes errors, stats, etc
59
72
  * [react-rails](https://github.com/reactjs/react-rails) fork for use with this workflow
60
73
  * Integration tests
@@ -0,0 +1,69 @@
1
+ module WebpackRails
2
+ # :nodoc:
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path("../../../../example", __FILE__)
5
+
6
+ desc "Install everything you need for a basic webpack-rails integration"
7
+
8
+ def add_foreman_to_gemfile
9
+ gem 'foreman'
10
+ end
11
+
12
+ def copy_procfile
13
+ copy_file "Procfile", "Procfile"
14
+ end
15
+
16
+ def copy_package_json
17
+ copy_file "package.json", "package.json"
18
+ end
19
+
20
+ def copy_webpack_conf
21
+ copy_file "webpack.config.js", "config/webpack.config.js"
22
+ end
23
+
24
+ def create_webpack_application_js
25
+ empty_directory "webpack"
26
+ create_file "webpack/application.js" do
27
+ <<-EOF.strip_heredoc
28
+ console.log("Hello world!");
29
+ EOF
30
+ end
31
+ end
32
+
33
+ def add_to_gitignore
34
+ append_to_file ".gitignore" do
35
+ <<-EOF.strip_heredoc
36
+ # Added by webpack-rails
37
+ /node_modules
38
+ /public/webpack
39
+ EOF
40
+ end
41
+ end
42
+
43
+ def run_npm_install
44
+ run "npm install" if yes?("Would you like us to run 'npm install' for you?")
45
+ end
46
+
47
+ def run_bundle_install
48
+ run "bundle install" if yes?("Would you like us to run 'bundle install' for you?")
49
+ end
50
+
51
+ def whats_next
52
+ puts <<-EOF.strip_heredoc
53
+
54
+ We've set up the basics of webpack-rails for you, but you'll still
55
+ need to:
56
+
57
+ 1. Add the 'application' entry point in to your layout, and
58
+ 2. Run 'foreman start' to run the webpack-dev-server and rails server
59
+
60
+ See the README.md for this gem at
61
+ https://github.com/mipearson/webpack-rails/blob/master/README.md
62
+ for more info.
63
+
64
+ Thanks for using webpack-rails!
65
+
66
+ EOF
67
+ end
68
+ end
69
+ end
@@ -1,6 +1,6 @@
1
1
  module Webpack
2
2
  # :nodoc:
3
3
  module Rails
4
- VERSION = "0.9.2"
4
+ VERSION = "0.9.3"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpack-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Pearson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-27 00:00:00.000000000 Z
11
+ date: 2015-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -35,6 +35,7 @@ files:
35
35
  - MIT-LICENSE
36
36
  - README.md
37
37
  - Rakefile
38
+ - lib/generators/webpack-rails/install_generator.rb
38
39
  - lib/tasks/webpack.rake
39
40
  - lib/webpack/rails.rb
40
41
  - lib/webpack/rails/helper.rb