webpack_assets 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0e9d65fb90841c3ffa7d48007eb0df7b18c525e3
4
+ data.tar.gz: 77b36788ea68d74584655ddb8975cde00e6c0a32
5
+ SHA512:
6
+ metadata.gz: be24b4a50966a5450a8b55f6390d2731fc8e777bdf0c2d0e40c0c256d5170db64fa00964a100df815a8c8c250779720217bbf83e1e985882c8852fa88e9e71ef
7
+ data.tar.gz: 86a8b260c32f0bb70315fde170f0050b8e8a48314377f8bd137015498958c7ea027ecac6ab33816b099ae1ec748157ed576b435938f4b6ccbafc021f78f13324
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in webpack_assets.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jason Madsen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # webpack_assets
2
+
3
+ adds a webpack build step into your rails `assets:precompile` rake task
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'webpack_assets'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install webpack_assets
18
+
19
+ ## Usage
20
+
21
+ `webpack_assets` assumes you have a webpack build with a `webpack.config.js` in
22
+ your rails project root. By default it also assumes your webpack build is
23
+ building a javascript bundle into `app/assets/javascripts/bundle.js`. If your
24
+ webpack config builds a file into a different location, or with a different
25
+ name, update your `config/application.rb` file:
26
+
27
+ ````ruby
28
+ # config/application.rb
29
+ config.webpack_build_path = 'app/assets/javascripts/your-js-file.js'
30
+ ````
31
+
32
+ Including the gem will automatically inject the webpack build into the
33
+ precompilation of assets. To run your webpack build manually execute:
34
+
35
+ bin/rake assets:webpack
36
+
37
+ To watch for changes from your webpack build files and compile per change, execute:
38
+
39
+ bin/rake assets:webpack:watch
40
+
41
+
42
+ ### Don't have a front end project yet?
43
+
44
+ `webpack_assets` assumes you have a webpack build. If you don't, never fear:
45
+
46
+ ```bash
47
+ cd <your-rails-root>
48
+ npm init #follow directions to create a project
49
+ npm install --save webpack
50
+ npm install --save jsx-loader
51
+ bin/rails g webpack_assets:webpack #will build a webpack.config.js
52
+
53
+ ```
54
+
55
+ Edit the entry point of the newly created `webpack.config.js` and you should be
56
+ on your way.
57
+
58
+
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/[my-github-username]/webpack_assets/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,18 @@
1
+ var webpack = require('webpack');
2
+
3
+ module.exports = {
4
+ entry: "./client_app/app/routes.js",
5
+ output: {
6
+ filename: "./app/assets/javascripts/bundle.js"
7
+ },
8
+ module: {
9
+ loaders: [
10
+ {test: /\.js$/, loader: 'jsx-loader'}
11
+ ]
12
+ },
13
+ plugins: [
14
+ new webpack.DefinePlugin({
15
+ 'process.env': {'NODE_ENV': JSON.stringify(process.env.NODE_ENV)}
16
+ })
17
+ ]
18
+ };
@@ -0,0 +1,23 @@
1
+ require 'rails/generators'
2
+ module WebpackAssets
3
+ class Webpack < Rails::Generators::Base
4
+
5
+ desc "create a default webpack.config.js file if one doesn't exist"
6
+
7
+ def self.source_root
8
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
9
+ end
10
+
11
+ def create_webpack_file
12
+ destination = 'webpack.config.js'
13
+ if File.exist?(destination)
14
+ puts "Skipping #{destination} because it already exists"
15
+ else
16
+ copy_file 'webpack.config.js', destination
17
+ puts "** update the entry point in 'webpack.config.js' "
18
+ puts "** update 'package.json' to include 'webpack' and 'jsx-loader' dependencies"
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ module WebpackAssets
2
+ class Railtie < Rails::Railtie
3
+
4
+ rake_tasks do
5
+ load 'webpack_assets/tasks/webpack.rake'
6
+ end
7
+
8
+ generators do
9
+ require 'webpack_assets/generators/webpack.rb'
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ # The webpack task must run before assets:environment task.
2
+ # Otherwise Sprockets cannot find the files that webpack produces.
3
+ # credit where it's due: http://www.tomdooner.com/2014/05/26/webpack.html
4
+
5
+ Rake::Task['assets:precompile']
6
+ .clear_prerequisites
7
+ .enhance(['assets:compile_environment'])
8
+
9
+ namespace :assets do
10
+
11
+ #In this task, set prerequisites for the assets:precompile task
12
+ task :compile_environment => :webpack do
13
+ Rake::Task['assets:environment'].invoke
14
+ end
15
+
16
+ desc 'Compile assets with webpack'
17
+ task :webpack do
18
+ sh "NODE_ENV=#{Rails.env} $(npm bin)/webpack"
19
+ end
20
+
21
+ # can you look up the file to clobber based on the webpack file?
22
+ # "#{app.config.root}/#{app.config.}
23
+ task :clobber do
24
+
25
+ path = begin
26
+ "#{Rails.root}/#{Rails.application.config.webpack_build_path}"
27
+ rescue
28
+ "#{Rails.root}/app/assets/javascripts/bundle.js"
29
+ end
30
+ rm_rf path
31
+ end
32
+
33
+ namespace :webpack do
34
+ desc 'compile with webpack and watch for changes'
35
+ task :watch do
36
+ sh "NODE_ENV=#{Rails.env} $(npm bin)/webpack --config webpack.config.js --watch --devtool inline-source-map"
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,3 @@
1
+ module WebpackAssets
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ require "webpack_assets/version"
2
+ require "webpack_assets/railtie" if defined?(Rails)
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'webpack_assets/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "webpack_assets"
8
+ spec.version = WebpackAssets::VERSION
9
+ spec.authors = ["Jason Madsen"]
10
+ spec.email = ["knomedia@gmail.com"]
11
+ spec.summary = %q{add webpack build into assets:precompile}
12
+ spec.description = %q{add webpack build into assets:precompile}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webpack_assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jason Madsen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: add webpack build into assets:precompile
42
+ email:
43
+ - knomedia@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/webpack_assets.rb
54
+ - lib/webpack_assets/generators/templates/webpack.config.js
55
+ - lib/webpack_assets/generators/webpack.rb
56
+ - lib/webpack_assets/railtie.rb
57
+ - lib/webpack_assets/tasks/webpack.rake
58
+ - lib/webpack_assets/version.rb
59
+ - webpack_assets.gemspec
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.4
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: add webpack build into assets:precompile
84
+ test_files: []