webpacker 1.2 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +93 -9
- data/Gemfile.lock +2 -2
- data/README.md +979 -93
- data/lib/install/angular.rb +2 -2
- data/lib/install/bin/webpack-dev-server.tt +20 -10
- data/lib/install/bin/webpack.tt +10 -15
- data/lib/install/config/.babelrc +13 -1
- data/lib/install/config/loaders/core/sass.js +3 -2
- data/lib/install/config/loaders/installers/elm.js +20 -0
- data/lib/install/config/loaders/installers/vue.js +1 -0
- data/lib/install/config/webpack/configuration.js +22 -13
- data/lib/install/config/webpack/development.js +17 -1
- data/lib/install/config/webpack/production.js +16 -2
- data/lib/install/config/webpack/shared.js +15 -11
- data/lib/install/config/{webpack/paths.yml → webpacker.yml} +12 -7
- data/lib/install/elm.rb +29 -0
- data/lib/install/examples/angular/tsconfig.json +1 -0
- data/lib/install/examples/elm/Main.elm +54 -0
- data/lib/install/examples/elm/hello_elm.js +11 -0
- data/lib/install/examples/vue/hello_vue.js +4 -8
- data/lib/install/react.rb +2 -2
- data/lib/install/template.rb +10 -11
- data/lib/install/vue.rb +2 -2
- data/lib/tasks/installers.rake +1 -0
- data/lib/tasks/webpacker.rake +11 -9
- data/lib/tasks/webpacker/check_webpack_binstubs.rake +11 -0
- data/lib/tasks/webpacker/check_yarn.rake +6 -3
- data/lib/tasks/webpacker/clobber.rake +3 -3
- data/lib/tasks/webpacker/compile.rake +14 -20
- data/lib/tasks/webpacker/verify_install.rake +2 -2
- data/lib/tasks/webpacker/yarn_install.rake +2 -2
- data/lib/webpacker.rb +16 -1
- data/lib/webpacker/compiler.rb +20 -0
- data/lib/webpacker/configuration.rb +30 -22
- data/lib/webpacker/env.rb +2 -6
- data/lib/webpacker/helper.rb +0 -2
- data/lib/webpacker/manifest.rb +23 -6
- data/lib/webpacker/version.rb +1 -1
- data/package.json +1 -1
- data/test/configuration_test.rb +32 -0
- data/test/env_test.rb +3 -5
- data/test/helper_test.rb +23 -0
- data/test/manifest_test.rb +30 -0
- data/test/test_app/config/secrets.yml +5 -0
- data/test/test_app/public/packs/manifest.json +4 -0
- data/test/webpacker_test.rb +2 -1
- metadata +20 -7
- data/lib/install/bin/yarn.tt +0 -11
- data/lib/install/config/webpack/development.server.js +0 -17
- data/lib/install/config/webpack/development.server.yml +0 -17
data/lib/webpacker/version.rb
CHANGED
data/package.json
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "webpacker_test"
|
2
|
+
|
3
|
+
class ConfigurationTest < Minitest::Test
|
4
|
+
def test_entry_path
|
5
|
+
entry_path = File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s
|
6
|
+
assert_equal Webpacker::Configuration.entry_path.to_s, entry_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_file_path
|
10
|
+
file_path = File.join(File.dirname(__FILE__), "test_app/config", "webpacker.yml").to_s
|
11
|
+
assert_equal Webpacker::Configuration.file_path.to_s, file_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_manifest_path
|
15
|
+
manifest_path = File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
|
16
|
+
assert_equal Webpacker::Configuration.manifest_path.to_s, manifest_path
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_output_path
|
20
|
+
output_path = File.join(File.dirname(__FILE__), "test_app/public/packs").to_s
|
21
|
+
assert_equal Webpacker::Configuration.output_path.to_s, output_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_source
|
25
|
+
assert_equal Webpacker::Configuration.source.to_s, "app/javascript"
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_source_path
|
29
|
+
source_path = File.join(File.dirname(__FILE__), "test_app/app/javascript").to_s
|
30
|
+
assert_equal Webpacker::Configuration.source_path.to_s, source_path
|
31
|
+
end
|
32
|
+
end
|
data/test/env_test.rb
CHANGED
@@ -3,14 +3,12 @@ require "webpacker_test"
|
|
3
3
|
class EnvTest < Minitest::Test
|
4
4
|
def test_current_env
|
5
5
|
assert_equal Webpacker::Env.current, "production"
|
6
|
-
|
7
|
-
|
8
|
-
def test_env_is_development?
|
9
|
-
refute_predicate Webpacker::Env, :development?
|
6
|
+
assert_equal Webpacker.env, "production"
|
7
|
+
assert Webpacker.env.production?
|
10
8
|
end
|
11
9
|
|
12
10
|
def test_file_path
|
13
|
-
correct_path = File.join(File.dirname(__FILE__), "config", "
|
11
|
+
correct_path = File.join(File.dirname(__FILE__), "test_app/config", "webpacker.yml").to_s
|
14
12
|
assert_equal Webpacker::Env.file_path.to_s, correct_path
|
15
13
|
end
|
16
14
|
end
|
data/test/helper_test.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "webpacker_test"
|
2
|
+
|
3
|
+
class HelperTest < ActionView::TestCase
|
4
|
+
def setup
|
5
|
+
@view = ActionView::Base.new
|
6
|
+
@view.extend Webpacker::Helper
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_asset_pack_path
|
10
|
+
assert_equal @view.asset_pack_path("bootstrap.js"), "/packs/bootstrap-300631c4f0e0f9c865bc.js"
|
11
|
+
assert_equal @view.asset_pack_path("bootstrap.css"), "/packs/bootstrap-c38deda30895059837cf.css"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_javascript_pack_tag
|
15
|
+
script = %(<script src="/packs/bootstrap-300631c4f0e0f9c865bc.js"></script>)
|
16
|
+
assert_equal @view.javascript_pack_tag("bootstrap.js"), script
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_stylesheet_pack_tag
|
20
|
+
style = %(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />)
|
21
|
+
assert_equal @view.stylesheet_pack_tag("bootstrap.css"), style
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "webpacker_test"
|
2
|
+
|
3
|
+
class ManifestTest < Minitest::Test
|
4
|
+
def test_file_path
|
5
|
+
file_path = File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
|
6
|
+
assert_equal Webpacker::Manifest.file_path.to_s, file_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_lookup_exception
|
10
|
+
manifest_path = File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
|
11
|
+
asset_file = "calendar.js"
|
12
|
+
|
13
|
+
error = assert_raises Webpacker::FileLoader::NotFoundError do
|
14
|
+
Webpacker::Manifest.lookup(asset_file)
|
15
|
+
end
|
16
|
+
|
17
|
+
assert_equal error.message, "Can't find #{asset_file} in #{manifest_path}. Is webpack still compiling?"
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_lookup_success
|
21
|
+
asset_file = "bootstrap.js"
|
22
|
+
assert_equal Webpacker::Manifest.lookup(asset_file), "/packs/bootstrap-300631c4f0e0f9c865bc.js"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_lookup_path
|
26
|
+
file_path = File.join(File.dirname(__FILE__), "test_app/public/packs", "bootstrap-300631c4f0e0f9c865bc.js").to_s
|
27
|
+
asset_file = "bootstrap.js"
|
28
|
+
assert_equal Webpacker::Manifest.lookup_path(asset_file).to_s, file_path
|
29
|
+
end
|
30
|
+
end
|
data/test/webpacker_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -88,7 +88,6 @@ files:
|
|
88
88
|
- lib/install/angular.rb
|
89
89
|
- lib/install/bin/webpack-dev-server.tt
|
90
90
|
- lib/install/bin/webpack.tt
|
91
|
-
- lib/install/bin/yarn.tt
|
92
91
|
- lib/install/config/.babelrc
|
93
92
|
- lib/install/config/.postcssrc.yml
|
94
93
|
- lib/install/config/loaders/core/assets.js
|
@@ -97,22 +96,24 @@ files:
|
|
97
96
|
- lib/install/config/loaders/core/erb.js
|
98
97
|
- lib/install/config/loaders/core/sass.js
|
99
98
|
- lib/install/config/loaders/installers/angular.js
|
99
|
+
- lib/install/config/loaders/installers/elm.js
|
100
100
|
- lib/install/config/loaders/installers/react.js
|
101
101
|
- lib/install/config/loaders/installers/vue.js
|
102
102
|
- lib/install/config/webpack/configuration.js
|
103
103
|
- lib/install/config/webpack/development.js
|
104
|
-
- lib/install/config/webpack/development.server.js
|
105
|
-
- lib/install/config/webpack/development.server.yml
|
106
|
-
- lib/install/config/webpack/paths.yml
|
107
104
|
- lib/install/config/webpack/production.js
|
108
105
|
- lib/install/config/webpack/shared.js
|
109
106
|
- lib/install/config/webpack/test.js
|
107
|
+
- lib/install/config/webpacker.yml
|
108
|
+
- lib/install/elm.rb
|
110
109
|
- lib/install/examples/angular/hello_angular.js
|
111
110
|
- lib/install/examples/angular/hello_angular/app/app.component.ts
|
112
111
|
- lib/install/examples/angular/hello_angular/app/app.module.ts
|
113
112
|
- lib/install/examples/angular/hello_angular/index.ts
|
114
113
|
- lib/install/examples/angular/hello_angular/polyfills.ts
|
115
114
|
- lib/install/examples/angular/tsconfig.json
|
115
|
+
- lib/install/examples/elm/Main.elm
|
116
|
+
- lib/install/examples/elm/hello_elm.js
|
116
117
|
- lib/install/examples/react/.babelrc
|
117
118
|
- lib/install/examples/react/hello_react.jsx
|
118
119
|
- lib/install/examples/vue/app.vue
|
@@ -124,6 +125,7 @@ files:
|
|
124
125
|
- lib/tasks/installers.rake
|
125
126
|
- lib/tasks/webpacker.rake
|
126
127
|
- lib/tasks/webpacker/check_node.rake
|
128
|
+
- lib/tasks/webpacker/check_webpack_binstubs.rake
|
127
129
|
- lib/tasks/webpacker/check_yarn.rake
|
128
130
|
- lib/tasks/webpacker/clobber.rake
|
129
131
|
- lib/tasks/webpacker/compile.rake
|
@@ -131,6 +133,7 @@ files:
|
|
131
133
|
- lib/tasks/webpacker/verify_install.rake
|
132
134
|
- lib/tasks/webpacker/yarn_install.rake
|
133
135
|
- lib/webpacker.rb
|
136
|
+
- lib/webpacker/compiler.rb
|
134
137
|
- lib/webpacker/configuration.rb
|
135
138
|
- lib/webpacker/env.rb
|
136
139
|
- lib/webpacker/file_loader.rb
|
@@ -139,7 +142,12 @@ files:
|
|
139
142
|
- lib/webpacker/railtie.rb
|
140
143
|
- lib/webpacker/version.rb
|
141
144
|
- package.json
|
145
|
+
- test/configuration_test.rb
|
142
146
|
- test/env_test.rb
|
147
|
+
- test/helper_test.rb
|
148
|
+
- test/manifest_test.rb
|
149
|
+
- test/test_app/config/secrets.yml
|
150
|
+
- test/test_app/public/packs/manifest.json
|
143
151
|
- test/webpacker_test.rb
|
144
152
|
- webpacker.gemspec
|
145
153
|
- yarn.lock
|
@@ -163,10 +171,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
171
|
version: '0'
|
164
172
|
requirements: []
|
165
173
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.6.
|
174
|
+
rubygems_version: 2.6.11
|
167
175
|
signing_key:
|
168
176
|
specification_version: 4
|
169
177
|
summary: Use Webpack to manage app-like JavaScript modules in Rails
|
170
178
|
test_files:
|
179
|
+
- test/configuration_test.rb
|
171
180
|
- test/env_test.rb
|
181
|
+
- test/helper_test.rb
|
182
|
+
- test/manifest_test.rb
|
183
|
+
- test/test_app/config/secrets.yml
|
184
|
+
- test/test_app/public/packs/manifest.json
|
172
185
|
- test/webpacker_test.rb
|
data/lib/install/bin/yarn.tt
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
<%= shebang %>
|
2
|
-
VENDOR_PATH = File.expand_path('..', __dir__)
|
3
|
-
Dir.chdir(VENDOR_PATH) do
|
4
|
-
begin
|
5
|
-
exec "yarnpkg #{ARGV.join(" ")}"
|
6
|
-
rescue Errno::ENOENT
|
7
|
-
$stderr.puts "Yarn executable was not detected in the system."
|
8
|
-
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
9
|
-
exit 1
|
10
|
-
end
|
11
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
// Note: You must restart bin/webpack-dev-server for changes to take effect
|
2
|
-
|
3
|
-
const { resolve } = require('path')
|
4
|
-
const merge = require('webpack-merge')
|
5
|
-
const devConfig = require('./development.js')
|
6
|
-
const { devServer, publicPath, paths } = require('./configuration.js')
|
7
|
-
|
8
|
-
module.exports = merge(devConfig, {
|
9
|
-
devServer: {
|
10
|
-
host: devServer.host,
|
11
|
-
port: devServer.port,
|
12
|
-
compress: true,
|
13
|
-
historyApiFallback: true,
|
14
|
-
contentBase: resolve(paths.output, paths.entry),
|
15
|
-
publicPath
|
16
|
-
}
|
17
|
-
})
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
2
|
-
|
3
|
-
default: &default
|
4
|
-
enabled: true
|
5
|
-
host: localhost
|
6
|
-
port: 8080
|
7
|
-
|
8
|
-
development:
|
9
|
-
<<: *default
|
10
|
-
|
11
|
-
test:
|
12
|
-
<<: *default
|
13
|
-
enabled: false
|
14
|
-
|
15
|
-
production:
|
16
|
-
<<: *default
|
17
|
-
enabled: false
|