webpack_react_on_rails 1.0.3 → 1.0.4
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 +4 -4
- data/lib/generators/webpack_react_on_rails/install_generator.rb +16 -25
- data/lib/{templates/webpack_initializer → generators/webpack_react_on_rails/templates/config/initializers/webpack.rb} +0 -0
- data/lib/generators/webpack_react_on_rails/templates/config/webpack/development.config.js +31 -0
- data/lib/generators/webpack_react_on_rails/templates/config/webpack/main.config.js +32 -0
- data/lib/{templates/webpack_production_config → generators/webpack_react_on_rails/templates/config/webpack/production.config.js} +7 -24
- data/lib/{templates/package → generators/webpack_react_on_rails/templates/package.json} +0 -0
- data/lib/tasks/webpack/compile.rake +1 -1
- data/lib/webpack_react_on_rails/action_view/webpack_helpers.rb +1 -1
- data/lib/webpack_react_on_rails/version.rb +1 -1
- data/test/dummy/config/application.rb +6 -0
- data/test/dummy/db/{development.sqlite3 → test.sqlite3} +0 -0
- data/test/dummy/log/development.log +0 -76
- data/test/dummy/log/test.log +925 -0
- data/test/generators/install_generator_test.rb +72 -0
- data/test/helpers/webpack_helpers_test.rb +48 -0
- data/test/test_helper.rb +3 -0
- metadata +44 -11
- data/lib/templates/webpack_development_config +0 -44
- data/test/react_redux_webpack_scaffolder_test.rb +0 -7
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'generators/webpack_react_on_rails/install_generator'
|
3
|
+
|
4
|
+
class InstallGeneratorTest < Rails::Generators::TestCase
|
5
|
+
tests ::WebpackReactOnRails::InstallGenerator
|
6
|
+
destination File.expand_path("../dummy/tmp", File.dirname(__FILE__))
|
7
|
+
setup :prepare_destination
|
8
|
+
|
9
|
+
test "create the correct configuration files" do
|
10
|
+
setup_files
|
11
|
+
|
12
|
+
run_generator
|
13
|
+
|
14
|
+
assert_file "./config/initializers/webpack.rb"
|
15
|
+
assert_file "./config/webpack/main.config.js"
|
16
|
+
assert_file "./config/webpack/development.config.js"
|
17
|
+
assert_file "./config/webpack/production.config.js"
|
18
|
+
assert_file "./package.json"
|
19
|
+
|
20
|
+
cleanup_files
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Creates all necessary test files
|
26
|
+
def setup_files
|
27
|
+
create_application_rb
|
28
|
+
create_production_rb
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_application_rb
|
32
|
+
path = File.join(Rails.root, "tmp", "config")
|
33
|
+
FileUtils.mkdir_p(path) unless File.exist?(path)
|
34
|
+
File.open(File.join(path, 'application.rb'), "w+") do |f|
|
35
|
+
f.write(
|
36
|
+
<<-APPLICATION.strip_heredoc
|
37
|
+
require File.expand_path('../boot', __FILE__)
|
38
|
+
|
39
|
+
require 'rails/all'
|
40
|
+
|
41
|
+
Bundler.require(*Rails.groups)
|
42
|
+
require "webpack_react_on_rails"
|
43
|
+
|
44
|
+
module Dummy
|
45
|
+
class Application < Rails::Application
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
APPLICATION
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def create_production_rb
|
55
|
+
path = File.join(Rails.root, "tmp", "config", "environments")
|
56
|
+
FileUtils.mkdir_p(path) unless File.exist?(path)
|
57
|
+
File.open(File.join(path, 'production.rb'), "w+") do |f|
|
58
|
+
f.write(
|
59
|
+
<<-PRODUCTION.strip_heredoc
|
60
|
+
Rails.application.configure do
|
61
|
+
|
62
|
+
end
|
63
|
+
PRODUCTION
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Removes all test files created
|
69
|
+
def cleanup_files
|
70
|
+
FileUtils.rm_rf(File.join(Rails.root, "tmp"))
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class WebpackHelpersTest < ActionView::TestCase
|
4
|
+
include ActionView::WebpackHelpers
|
5
|
+
|
6
|
+
test "return correct script tag for the given bundle name" do
|
7
|
+
Rails.configuration.webpack[:use_manifest] = false
|
8
|
+
|
9
|
+
bundle_name = 'index-bundle'
|
10
|
+
assert_equal("<script src=\"/assets/#{bundle_name}.js\"></script>", webpack_bundle_tag(bundle_name))
|
11
|
+
end
|
12
|
+
|
13
|
+
test "return correct script tag when using manifest" do
|
14
|
+
bundle_name = 'index'
|
15
|
+
bundle_manifest = 'random-base64-string'
|
16
|
+
|
17
|
+
Rails.configuration.webpack[:use_manifest] = true
|
18
|
+
Rails.configuration.webpack[:asset_manifest] = {
|
19
|
+
bundle_name => "#{bundle_name}-bundle-#{bundle_manifest}"
|
20
|
+
}
|
21
|
+
|
22
|
+
assert_equal("<script src=\"/assets/#{bundle_name}-bundle-#{bundle_manifest}.js\"></script>", webpack_bundle_tag(bundle_name))
|
23
|
+
end
|
24
|
+
|
25
|
+
test "return correct script tag for the given bundle path" do
|
26
|
+
Rails.configuration.webpack[:use_manifest] = false
|
27
|
+
Rails.configuration.webpack[:asset_manifest] = {}
|
28
|
+
|
29
|
+
bundle_name = 'bundle/index'
|
30
|
+
assert_equal("<script src=\"/assets/#{bundle_name}.js\"></script>", webpack_bundle_tag(bundle_name))
|
31
|
+
end
|
32
|
+
|
33
|
+
test "return correct script tag for the given bundle path when using manifest" do
|
34
|
+
Rails.configuration.webpack[:asset_manifest] = {}
|
35
|
+
|
36
|
+
bundle_name = 'bundle/index'
|
37
|
+
bundle_manifest = 'random-base64-string'
|
38
|
+
|
39
|
+
bundle_actual_name = bundle_name.split('/').last
|
40
|
+
|
41
|
+
Rails.configuration.webpack[:use_manifest] = true
|
42
|
+
Rails.configuration.webpack[:asset_manifest] = {
|
43
|
+
bundle_actual_name => "#{bundle_actual_name}-bundle-#{bundle_manifest}"
|
44
|
+
}
|
45
|
+
|
46
|
+
assert_equal("<script src=\"/assets/#{bundle_name}-bundle-#{bundle_manifest}.js\"></script>", webpack_bundle_tag(bundle_name))
|
47
|
+
end
|
48
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -5,6 +5,9 @@ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
|
5
5
|
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
6
|
require "rails/test_help"
|
7
7
|
|
8
|
+
require 'action_view/test_case'
|
9
|
+
require 'pry'
|
10
|
+
|
8
11
|
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
9
12
|
# to be shown.
|
10
13
|
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpack_react_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hyun Sik Kang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sqlite3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rails
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,11 +68,12 @@ files:
|
|
40
68
|
- MIT-LICENSE
|
41
69
|
- Rakefile
|
42
70
|
- lib/generators/webpack_react_on_rails/install_generator.rb
|
71
|
+
- lib/generators/webpack_react_on_rails/templates/config/initializers/webpack.rb
|
72
|
+
- lib/generators/webpack_react_on_rails/templates/config/webpack/development.config.js
|
73
|
+
- lib/generators/webpack_react_on_rails/templates/config/webpack/main.config.js
|
74
|
+
- lib/generators/webpack_react_on_rails/templates/config/webpack/production.config.js
|
75
|
+
- lib/generators/webpack_react_on_rails/templates/package.json
|
43
76
|
- lib/tasks/webpack/compile.rake
|
44
|
-
- lib/templates/package
|
45
|
-
- lib/templates/webpack_development_config
|
46
|
-
- lib/templates/webpack_initializer
|
47
|
-
- lib/templates/webpack_production_config
|
48
77
|
- lib/webpack_react_on_rails.rb
|
49
78
|
- lib/webpack_react_on_rails/action_view/webpack_helpers.rb
|
50
79
|
- lib/webpack_react_on_rails/railtie.rb
|
@@ -79,15 +108,17 @@ files:
|
|
79
108
|
- test/dummy/config/locales/en.yml
|
80
109
|
- test/dummy/config/routes.rb
|
81
110
|
- test/dummy/config/secrets.yml
|
82
|
-
- test/dummy/db/
|
111
|
+
- test/dummy/db/test.sqlite3
|
83
112
|
- test/dummy/log/development.log
|
113
|
+
- test/dummy/log/test.log
|
84
114
|
- test/dummy/public/404.html
|
85
115
|
- test/dummy/public/422.html
|
86
116
|
- test/dummy/public/500.html
|
87
117
|
- test/dummy/public/favicon.ico
|
88
|
-
- test/
|
118
|
+
- test/generators/install_generator_test.rb
|
119
|
+
- test/helpers/webpack_helpers_test.rb
|
89
120
|
- test/test_helper.rb
|
90
|
-
homepage: https://github.com/brokenfingers/webpack-react-on-rails
|
121
|
+
homepage: https://github.com/brokenfingers/webpack-react-on-rails
|
91
122
|
licenses:
|
92
123
|
- MIT
|
93
124
|
metadata: {}
|
@@ -140,13 +171,15 @@ test_files:
|
|
140
171
|
- test/dummy/config/routes.rb
|
141
172
|
- test/dummy/config/secrets.yml
|
142
173
|
- test/dummy/config.ru
|
143
|
-
- test/dummy/db/
|
174
|
+
- test/dummy/db/test.sqlite3
|
144
175
|
- test/dummy/log/development.log
|
176
|
+
- test/dummy/log/test.log
|
145
177
|
- test/dummy/public/404.html
|
146
178
|
- test/dummy/public/422.html
|
147
179
|
- test/dummy/public/500.html
|
148
180
|
- test/dummy/public/favicon.ico
|
149
181
|
- test/dummy/Rakefile
|
150
182
|
- test/dummy/README.rdoc
|
151
|
-
- test/
|
183
|
+
- test/generators/install_generator_test.rb
|
184
|
+
- test/helpers/webpack_helpers_test.rb
|
152
185
|
- test/test_helper.rb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
var path = require('path');
|
2
|
-
var webpack = require('webpack');
|
3
|
-
|
4
|
-
var config = module.exports = {
|
5
|
-
// the base path which will be used to resolve entry points
|
6
|
-
context: __dirname,
|
7
|
-
|
8
|
-
// the main entry point for our application's frontend js
|
9
|
-
// anything not required by this file will never end up in the compiled bundle
|
10
|
-
// passing an object provides multiple entries points
|
11
|
-
entry: {
|
12
|
-
webpackDev: 'webpack/hot/only-dev-server',
|
13
|
-
// The entry point for the application js i.e. './app/frontend/javascripts/app.js'
|
14
|
-
}
|
15
|
-
};
|
16
|
-
|
17
|
-
config.module = {
|
18
|
-
loaders: [{
|
19
|
-
test: /\.jsx?$/,
|
20
|
-
exclude: /node_modules/,
|
21
|
-
loader: 'babel'
|
22
|
-
}]
|
23
|
-
};
|
24
|
-
|
25
|
-
// this config dicates where compiled bundles end up
|
26
|
-
config.output = {
|
27
|
-
// this is our app/assets/javascripts directory, which is part of the Sprockets pipeline
|
28
|
-
path: path.join(__dirname, 'app', 'assets', 'javascript', 'bundle'),
|
29
|
-
|
30
|
-
// the filename of the compiled bundle, e.g. app/assets/javascripts/bundle.js
|
31
|
-
filename: '[name]-bundle.js',
|
32
|
-
|
33
|
-
// if the webpack code-splitting feature is enabled, this is the path it'll use to download bundles
|
34
|
-
publicPath: '/assets',
|
35
|
-
};
|
36
|
-
|
37
|
-
config.resolve = {
|
38
|
-
extensions: ['', '.js', '.jsx'],
|
39
|
-
modulesDirectories: ['node_modules'],
|
40
|
-
};
|
41
|
-
|
42
|
-
config.plugins = [
|
43
|
-
new webpack.HotModuleReplacementPlugin()
|
44
|
-
];
|