webpacker 4.0.0.pre.pre.2 → 4.0.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.node-version +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +22 -2
- data/Gemfile.lock +63 -53
- data/README.md +39 -23
- data/Rakefile +1 -2
- data/docs/cloud9.md +1 -1
- data/docs/css.md +1 -1
- data/docs/es6.md +4 -4
- data/docs/testing.md +1 -1
- data/docs/webpack.md +4 -0
- data/gemfiles/Gemfile-rails.4.2.x +1 -1
- data/gemfiles/Gemfile-rails.5.0.x +1 -1
- data/gemfiles/Gemfile-rails.5.1.x +1 -1
- data/gemfiles/Gemfile-rails.5.2.x +10 -0
- data/lib/install/angular.rb +2 -2
- data/lib/install/bin/webpack +6 -2
- data/lib/install/bin/webpack-dev-server +6 -2
- data/lib/install/coffee.rb +1 -1
- data/lib/install/config/.babelrc +35 -12
- data/lib/install/config/.browserslistrc +1 -0
- data/lib/install/config/.postcssrc.yml +1 -1
- data/lib/install/config/webpacker.yml +4 -0
- data/lib/install/elm.rb +5 -4
- data/lib/install/erb.rb +1 -1
- data/lib/install/examples/react/.babelrc +43 -2
- data/lib/install/examples/stimulus/application.js +1 -6
- data/lib/install/examples/stimulus/controllers/index.js +9 -0
- data/lib/install/examples/typescript/tsconfig.json +4 -0
- data/lib/install/examples/vue/hello_vue.js +1 -1
- data/lib/install/loaders/elm.js +3 -4
- data/lib/install/loaders/vue.js +0 -5
- data/lib/install/react.rb +5 -4
- data/lib/install/template.rb +16 -19
- data/lib/install/typescript.rb +2 -2
- data/lib/install/vue.rb +3 -3
- data/lib/tasks/installers.rake +4 -2
- data/lib/tasks/webpacker.rake +1 -0
- data/lib/tasks/webpacker/binstubs.rake +3 -2
- data/lib/tasks/webpacker/info.rake +19 -0
- data/lib/tasks/webpacker/install.rake +3 -2
- data/lib/tasks/webpacker/verify_install.rake +1 -4
- data/lib/webpacker.rb +1 -0
- data/lib/webpacker/commands.rb +0 -1
- data/lib/webpacker/compiler.rb +10 -3
- data/lib/webpacker/configuration.rb +17 -7
- data/lib/webpacker/dev_server.rb +8 -4
- data/lib/webpacker/dev_server_proxy.rb +4 -0
- data/lib/webpacker/dev_server_runner.rb +17 -9
- data/lib/webpacker/env.rb +1 -1
- data/lib/webpacker/instance.rb +6 -2
- data/lib/webpacker/railtie.rb +15 -6
- data/lib/webpacker/runner.rb +3 -3
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +2 -2
- data/package.json +40 -33
- data/package/__tests__/config.js +17 -1
- data/package/__tests__/production.js +3 -1
- data/package/__tests__/staging.js +4 -2
- data/package/__tests__/test.js +4 -1
- data/package/config.js +9 -1
- data/package/config_types/config_list.js +5 -6
- data/package/dev_server.js +1 -1
- data/package/env.js +2 -2
- data/package/environments/base.js +26 -27
- data/package/environments/production.js +10 -1
- data/package/utils/__tests__/deep_assign.js +27 -6
- data/package/utils/deep_assign.js +1 -1
- data/package/utils/deep_merge.js +5 -6
- data/package/utils/get_style_rule.js +2 -5
- data/package/utils/helpers.js +3 -4
- data/package/utils/objectify.js +1 -2
- data/test/compiler_test.rb +2 -2
- data/test/configuration_test.rb +46 -22
- data/test/test_app/config.ru +5 -0
- data/test/test_helper.rb +3 -3
- data/test/webpacker_test.rb +13 -0
- data/webpacker.gemspec +5 -0
- data/yarn.lock +2758 -3258
- metadata +14 -3
data/lib/install/typescript.rb
CHANGED
@@ -31,10 +31,10 @@ say "Copying tsconfig.json to the Rails root directory for typescript"
|
|
31
31
|
copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json"
|
32
32
|
|
33
33
|
say "Updating webpack paths to include .ts file extension"
|
34
|
-
insert_into_file Webpacker.config.config_path, "
|
34
|
+
insert_into_file Webpacker.config.config_path, "- .ts\n".indent(4), after: /extensions:\n/
|
35
35
|
|
36
36
|
say "Updating webpack paths to include .tsx file extension"
|
37
|
-
insert_into_file Webpacker.config.config_path, "
|
37
|
+
insert_into_file Webpacker.config.config_path, "- .tsx\n".indent(4), after: /extensions:\n/
|
38
38
|
|
39
39
|
say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
|
40
40
|
copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
|
data/lib/install/vue.rb
CHANGED
@@ -22,7 +22,7 @@ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
|
22
22
|
before: "module.exports"
|
23
23
|
|
24
24
|
say "Updating webpack paths to include .vue file extension"
|
25
|
-
insert_into_file Webpacker.config.config_path, "
|
25
|
+
insert_into_file Webpacker.config.config_path, "- .vue\n".indent(4), after: /extensions:\n/
|
26
26
|
|
27
27
|
say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
|
28
28
|
copy_file "#{__dir__}/examples/vue/hello_vue.js",
|
@@ -40,9 +40,9 @@ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
|
|
40
40
|
say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
|
41
41
|
say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
|
42
42
|
say "if Rails.env.development?", :yellow
|
43
|
-
say "
|
43
|
+
say " policy.script_src :self, :https, :unsafe_eval", :yellow
|
44
44
|
say "else", :yellow
|
45
|
-
say "
|
45
|
+
say " policy.script_src :self, :https", :yellow
|
46
46
|
say "end", :yellow
|
47
47
|
end
|
48
48
|
|
data/lib/tasks/installers.rake
CHANGED
@@ -13,6 +13,8 @@ dependencies = {
|
|
13
13
|
"Angular": [:typescript]
|
14
14
|
}
|
15
15
|
|
16
|
+
bin_path = ENV["BUNDLE_BIN"] || "./bin"
|
17
|
+
|
16
18
|
namespace :webpacker do
|
17
19
|
namespace :install do
|
18
20
|
installers.each do |name, task_name|
|
@@ -21,9 +23,9 @@ namespace :webpacker do
|
|
21
23
|
template = File.expand_path("../install/#{task_name}.rb", __dir__)
|
22
24
|
base_path =
|
23
25
|
if Rails::VERSION::MAJOR >= 5
|
24
|
-
"#{RbConfig.ruby}
|
26
|
+
"#{RbConfig.ruby} #{bin_path}/rails app:template"
|
25
27
|
else
|
26
|
-
"#{RbConfig.ruby}
|
28
|
+
"#{RbConfig.ruby} #{bin_path}/rake rails:template"
|
27
29
|
end
|
28
30
|
|
29
31
|
dependencies[name] ||= []
|
data/lib/tasks/webpacker.rake
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
tasks = {
|
2
|
+
"webpacker:info" => "Provides information on Webpacker's environment",
|
2
3
|
"webpacker:install" => "Installs and setup webpack with Yarn",
|
3
4
|
"webpacker:compile" => "Compiles webpack bundles based on environment",
|
4
5
|
"webpacker:clobber" => "Removes the webpack compiled output directory",
|
@@ -1,12 +1,13 @@
|
|
1
1
|
binstubs_template_path = File.expand_path("../../install/binstubs.rb", __dir__).freeze
|
2
|
+
bin_path = ENV["BUNDLE_BIN"] || "./bin"
|
2
3
|
|
3
4
|
namespace :webpacker do
|
4
5
|
desc "Installs Webpacker binstubs in this application"
|
5
6
|
task binstubs: [:check_node, :check_yarn] do
|
6
7
|
if Rails::VERSION::MAJOR >= 5
|
7
|
-
exec "#{RbConfig.ruby}
|
8
|
+
exec "#{RbConfig.ruby} #{bin_path}/rails app:template LOCATION=#{binstubs_template_path}"
|
8
9
|
else
|
9
|
-
exec "#{RbConfig.ruby}
|
10
|
+
exec "#{RbConfig.ruby} #{bin_path}/rake rails:template LOCATION=#{binstubs_template_path}"
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "webpacker/version"
|
2
|
+
|
3
|
+
namespace :webpacker do
|
4
|
+
desc "Provide information on Webpacker's environment"
|
5
|
+
task :info do
|
6
|
+
$stdout.puts "Ruby: #{`ruby --version`}"
|
7
|
+
$stdout.puts "Rails: #{Rails.version}"
|
8
|
+
$stdout.puts "Webpacker: #{Webpacker::VERSION}"
|
9
|
+
$stdout.puts "Node: #{`node --version`}"
|
10
|
+
$stdout.puts "Yarn: #{`yarn --version`}"
|
11
|
+
|
12
|
+
$stdout.puts "\n"
|
13
|
+
$stdout.puts "@rails/webpacker: \n#{`npm list @rails/webpacker version`}"
|
14
|
+
|
15
|
+
$stdout.puts "Is bin/webpack present?: #{File.exist? 'bin/webpack'}"
|
16
|
+
$stdout.puts "Is bin/webpack-dev-server present?: #{File.exist? 'bin/webpack-dev-server'}"
|
17
|
+
$stdout.puts "Is bin/yarn present?: #{File.exist? 'bin/yarn'}"
|
18
|
+
end
|
19
|
+
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
install_template_path = File.expand_path("../../install/template.rb", __dir__).freeze
|
2
|
+
bin_path = ENV["BUNDLE_BIN"] || "./bin"
|
2
3
|
|
3
4
|
namespace :webpacker do
|
4
5
|
desc "Install Webpacker in this application"
|
5
6
|
task install: [:check_node, :check_yarn] do
|
6
7
|
if Rails::VERSION::MAJOR >= 5
|
7
|
-
exec "#{RbConfig.ruby}
|
8
|
+
exec "#{RbConfig.ruby} #{bin_path}/rails app:template LOCATION=#{install_template_path}"
|
8
9
|
else
|
9
|
-
exec "#{RbConfig.ruby}
|
10
|
+
exec "#{RbConfig.ruby} #{bin_path}/rake rails:template LOCATION=#{install_template_path}"
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -3,10 +3,7 @@ require "webpacker/configuration"
|
|
3
3
|
namespace :webpacker do
|
4
4
|
desc "Verifies if Webpacker is installed"
|
5
5
|
task verify_install: [:check_node, :check_yarn, :check_binstubs] do
|
6
|
-
|
7
|
-
$stdout.puts "Webpacker is installed 🎉 🍰"
|
8
|
-
$stdout.puts "Using #{Webpacker.config.config_path} file for setting up webpack paths"
|
9
|
-
else
|
6
|
+
unless Webpacker.config.config_path.exist?
|
10
7
|
$stderr.puts "Configuration config/webpacker.yml file not found. \n"\
|
11
8
|
"Make sure webpacker:install is run successfully before " \
|
12
9
|
"running dependent tasks"
|
data/lib/webpacker.rb
CHANGED
data/lib/webpacker/commands.rb
CHANGED
data/lib/webpacker/compiler.rb
CHANGED
@@ -40,11 +40,17 @@ class Webpacker::Compiler
|
|
40
40
|
private
|
41
41
|
def last_compilation_digest
|
42
42
|
compilation_digest_path.read if compilation_digest_path.exist? && config.public_manifest_path.exist?
|
43
|
+
rescue Errno::ENOENT, Errno::ENOTDIR
|
43
44
|
end
|
44
45
|
|
45
46
|
def watched_files_digest
|
46
47
|
files = Dir[*default_watched_paths, *watched_paths].reject { |f| File.directory?(f) }
|
47
|
-
|
48
|
+
file_ids = if ENV["CI"]
|
49
|
+
files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
|
50
|
+
else
|
51
|
+
files.map { |f| "#{File.basename(f)}/#{File.mtime(f).utc.to_i}" }
|
52
|
+
end
|
53
|
+
Digest::SHA1.hexdigest(file_ids.join("/"))
|
48
54
|
end
|
49
55
|
|
50
56
|
def record_compilation_digest
|
@@ -54,12 +60,13 @@ class Webpacker::Compiler
|
|
54
60
|
|
55
61
|
def remove_compilation_digest
|
56
62
|
compilation_digest_path.delete if compilation_digest_path.exist?
|
63
|
+
rescue Errno::ENOENT, Errno::ENOTDIR
|
57
64
|
end
|
58
65
|
|
59
66
|
def run_webpack
|
60
67
|
logger.info "Compiling…"
|
61
68
|
|
62
|
-
|
69
|
+
stdout, sterr , status = Open3.capture3(webpack_env, "#{RbConfig.ruby} #{@webpacker.root_path}/bin/webpack")
|
63
70
|
|
64
71
|
if status.success?
|
65
72
|
logger.info "Compiled all packs in #{config.public_output_path}"
|
@@ -80,7 +87,7 @@ class Webpacker::Compiler
|
|
80
87
|
end
|
81
88
|
|
82
89
|
def compilation_digest_path
|
83
|
-
config.cache_path.join("
|
90
|
+
config.cache_path.join("last-compilation-digest-#{Webpacker.env}")
|
84
91
|
end
|
85
92
|
|
86
93
|
def webpack_env
|
@@ -1,12 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "yaml"
|
2
|
+
require "active_support/core_ext/hash/keys"
|
3
|
+
require "active_support/core_ext/hash/indifferent_access"
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
end
|
5
|
+
class Webpacker::Configuration
|
6
|
+
attr_reader :root_path, :config_path, :env
|
7
7
|
|
8
|
-
def
|
9
|
-
@
|
8
|
+
def initialize(root_path:, config_path:, env:)
|
9
|
+
@root_path = root_path
|
10
|
+
@config_path = config_path
|
11
|
+
@env = env
|
10
12
|
end
|
11
13
|
|
12
14
|
def dev_server
|
@@ -57,6 +59,14 @@ class Webpacker::Configuration
|
|
57
59
|
fetch(:extensions)
|
58
60
|
end
|
59
61
|
|
62
|
+
def check_yarn_integrity=(value)
|
63
|
+
data[:check_yarn_integrity] = value
|
64
|
+
end
|
65
|
+
|
66
|
+
def check_yarn_integrity?
|
67
|
+
fetch(:check_yarn_integrity)
|
68
|
+
end
|
69
|
+
|
60
70
|
private
|
61
71
|
def fetch(key)
|
62
72
|
data.fetch(key, defaults[key])
|
data/lib/webpacker/dev_server.rb
CHANGED
@@ -3,10 +3,10 @@ class Webpacker::DevServer
|
|
3
3
|
# Webpacker.dev_server.connect_timeout = 1
|
4
4
|
cattr_accessor(:connect_timeout) { 0.01 }
|
5
5
|
|
6
|
-
|
6
|
+
attr_reader :config
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(config)
|
9
|
+
@config = config
|
10
10
|
end
|
11
11
|
|
12
12
|
def running?
|
@@ -54,12 +54,16 @@ class Webpacker::DevServer
|
|
54
54
|
"#{host}:#{port}"
|
55
55
|
end
|
56
56
|
|
57
|
+
def pretty?
|
58
|
+
fetch(:pretty)
|
59
|
+
end
|
60
|
+
|
57
61
|
private
|
58
62
|
def fetch(key)
|
59
63
|
ENV["WEBPACKER_DEV_SERVER_#{key.upcase}"] || config.dev_server.fetch(key, defaults[key])
|
60
64
|
end
|
61
65
|
|
62
66
|
def defaults
|
63
|
-
config.send(:defaults)[:dev_server]
|
67
|
+
config.send(:defaults)[:dev_server] || {}
|
64
68
|
end
|
65
69
|
end
|
@@ -11,6 +11,10 @@ class Webpacker::DevServerProxy < Rack::Proxy
|
|
11
11
|
def perform_request(env)
|
12
12
|
if env["PATH_INFO"].start_with?("/#{public_output_uri_path}") && Webpacker.dev_server.running?
|
13
13
|
env["HTTP_HOST"] = env["HTTP_X_FORWARDED_HOST"] = env["HTTP_X_FORWARDED_SERVER"] = Webpacker.dev_server.host_with_port
|
14
|
+
env["HTTP_X_FORWARDED_PROTO"] = env["HTTP_X_FORWARDED_SCHEME"] = Webpacker.dev_server.protocol
|
15
|
+
unless Webpacker.dev_server.https?
|
16
|
+
env["HTTPS"] = env["HTTP_X_FORWARDED_SSL"] = "off"
|
17
|
+
end
|
14
18
|
env["SCRIPT_NAME"] = ""
|
15
19
|
|
16
20
|
super(env)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "shellwords"
|
2
|
-
require "yaml"
|
3
2
|
require "socket"
|
3
|
+
require "webpacker/configuration"
|
4
|
+
require "webpacker/dev_server"
|
4
5
|
require "webpacker/runner"
|
5
6
|
|
6
7
|
module Webpacker
|
@@ -13,15 +14,22 @@ module Webpacker
|
|
13
14
|
|
14
15
|
private
|
15
16
|
def load_config
|
16
|
-
|
17
|
-
dev_server = YAML.load_file(@config_file)[ENV["RAILS_ENV"]]["dev_server"]
|
17
|
+
app_root = Pathname.new(@app_path)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
config = Configuration.new(
|
20
|
+
root_path: app_root,
|
21
|
+
config_path: app_root.join("config/webpacker.yml"),
|
22
|
+
env: ENV["RAILS_ENV"]
|
23
|
+
)
|
24
|
+
|
25
|
+
dev_server = DevServer.new(config)
|
26
|
+
|
27
|
+
@hostname = dev_server.host
|
28
|
+
@port = dev_server.port
|
29
|
+
@pretty = dev_server.pretty?
|
22
30
|
|
23
31
|
rescue Errno::ENOENT, NoMethodError
|
24
|
-
$stdout.puts "webpack dev_server configuration not found in #{
|
32
|
+
$stdout.puts "webpack dev_server configuration not found in #{config.config_path}[#{ENV["RAILS_ENV"]}]."
|
25
33
|
$stdout.puts "Please run bundle exec rails webpacker:install to install Webpacker"
|
26
34
|
exit!
|
27
35
|
end
|
@@ -36,9 +44,9 @@ module Webpacker
|
|
36
44
|
end
|
37
45
|
|
38
46
|
def execute_cmd
|
39
|
-
env =
|
47
|
+
env = Webpacker::Compiler.env
|
40
48
|
cmd = [
|
41
|
-
"#{@
|
49
|
+
"#{@node_modules_bin_path}/webpack-dev-server",
|
42
50
|
"--config", @webpack_config
|
43
51
|
]
|
44
52
|
cmd += ["--progress", "--color"] if @pretty
|
data/lib/webpacker/env.rb
CHANGED
data/lib/webpacker/instance.rb
CHANGED
@@ -12,7 +12,11 @@ class Webpacker::Instance
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def config
|
15
|
-
@config ||= Webpacker::Configuration.new
|
15
|
+
@config ||= Webpacker::Configuration.new(
|
16
|
+
root_path: root_path,
|
17
|
+
config_path: config_path,
|
18
|
+
env: env
|
19
|
+
)
|
16
20
|
end
|
17
21
|
|
18
22
|
def compiler
|
@@ -20,7 +24,7 @@ class Webpacker::Instance
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def dev_server
|
23
|
-
@dev_server ||= Webpacker::DevServer.new
|
27
|
+
@dev_server ||= Webpacker::DevServer.new config
|
24
28
|
end
|
25
29
|
|
26
30
|
def manifest
|
data/lib/webpacker/railtie.rb
CHANGED
@@ -6,7 +6,12 @@ require "webpacker/dev_server_proxy"
|
|
6
6
|
class Webpacker::Engine < ::Rails::Engine
|
7
7
|
# Allows Webpacker config values to be set via Rails env config files
|
8
8
|
config.webpacker = ActiveSupport::OrderedOptions.new
|
9
|
-
|
9
|
+
|
10
|
+
initializer "webpacker.set_configs" do |app|
|
11
|
+
if app.config.webpacker.key?(:check_yarn_integrity)
|
12
|
+
Webpacker.config.check_yarn_integrity = app.config.webpacker.check_yarn_integrity
|
13
|
+
end
|
14
|
+
end
|
10
15
|
|
11
16
|
# ================================
|
12
17
|
# Check Yarn Integrity Initializer
|
@@ -24,7 +29,7 @@ class Webpacker::Engine < ::Rails::Engine
|
|
24
29
|
# - edit config/environments/production.rb
|
25
30
|
# - add `config.webpacker.check_yarn_integrity = true`
|
26
31
|
initializer "webpacker.yarn_check" do |app|
|
27
|
-
if File.exist?("yarn.lock") &&
|
32
|
+
if File.exist?("yarn.lock") && Webpacker.config.config_path.exist? && Webpacker.config.check_yarn_integrity?
|
28
33
|
output = `yarn check --integrity 2>&1`
|
29
34
|
|
30
35
|
unless $?.success?
|
@@ -34,8 +39,8 @@ class Webpacker::Engine < ::Rails::Engine
|
|
34
39
|
$stderr.puts " Please run `yarn install` to update."
|
35
40
|
$stderr.puts "========================================"
|
36
41
|
$stderr.puts "\n\n"
|
37
|
-
$stderr.puts "To disable this check, please
|
38
|
-
$stderr.puts "to your
|
42
|
+
$stderr.puts "To disable this check, please change `check_yarn_integrity`"
|
43
|
+
$stderr.puts "to `false` in your webpacker config file (config/webpacker.yml)."
|
39
44
|
$stderr.puts "\n\n"
|
40
45
|
$stderr.puts output
|
41
46
|
$stderr.puts "\n\n"
|
@@ -46,7 +51,8 @@ class Webpacker::Engine < ::Rails::Engine
|
|
46
51
|
end
|
47
52
|
|
48
53
|
initializer "webpacker.proxy" do |app|
|
49
|
-
|
54
|
+
insert_middleware = Webpacker.config.dev_server.present? rescue nil
|
55
|
+
if insert_middleware
|
50
56
|
app.middleware.insert_before 0,
|
51
57
|
Rails::VERSION::MAJOR >= 5 ?
|
52
58
|
Webpacker::DevServerProxy : "Webpacker::DevServerProxy", ssl_verify_none: true
|
@@ -76,7 +82,10 @@ class Webpacker::Engine < ::Rails::Engine
|
|
76
82
|
initializer "webpacker.bootstrap" do
|
77
83
|
if defined?(Rails::Server) || defined?(Rails::Console)
|
78
84
|
Webpacker.bootstrap
|
79
|
-
|
85
|
+
if defined?(Spring)
|
86
|
+
Spring.after_fork { Webpacker.bootstrap }
|
87
|
+
Spring.watch(Webpacker.config.config_path)
|
88
|
+
end
|
80
89
|
end
|
81
90
|
end
|
82
91
|
end
|
data/lib/webpacker/runner.rb
CHANGED
@@ -9,9 +9,9 @@ module Webpacker
|
|
9
9
|
def initialize(argv)
|
10
10
|
@argv = argv
|
11
11
|
|
12
|
-
@app_path
|
13
|
-
@
|
14
|
-
@webpack_config
|
12
|
+
@app_path = File.expand_path(".", Dir.pwd)
|
13
|
+
@node_modules_bin_path = ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] || `yarn bin`.chomp
|
14
|
+
@webpack_config = File.join(@app_path, "config/webpack/#{ENV["NODE_ENV"]}.js")
|
15
15
|
|
16
16
|
unless File.exist?(@webpack_config)
|
17
17
|
$stderr.puts "webpack config #{@webpack_config} not found, please run 'bundle exec rails webpacker:install' to install Webpacker with default configs or add the missing config file for your custom environment."
|
data/lib/webpacker/version.rb
CHANGED
@@ -4,8 +4,8 @@ require "webpacker/runner"
|
|
4
4
|
module Webpacker
|
5
5
|
class WebpackRunner < Webpacker::Runner
|
6
6
|
def run
|
7
|
-
env =
|
8
|
-
cmd = [ "#{@
|
7
|
+
env = Webpacker::Compiler.env
|
8
|
+
cmd = [ "#{@node_modules_bin_path}/webpack", "--config", @webpack_config ] + @argv
|
9
9
|
|
10
10
|
Dir.chdir(@app_path) do
|
11
11
|
exec env, *cmd
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rails/webpacker",
|
3
|
-
"version": "4.0.0-pre.
|
3
|
+
"version": "4.0.0-pre.3",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"main": "package/index.js",
|
6
6
|
"files": [
|
@@ -8,43 +8,50 @@
|
|
8
8
|
"lib/install/config/webpacker.yml"
|
9
9
|
],
|
10
10
|
"engines": {
|
11
|
-
"node": ">=6.
|
12
|
-
"yarn": ">=0.
|
11
|
+
"node": ">=6.14.0",
|
12
|
+
"yarn": ">=1.0.0"
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
|
-
"babel
|
16
|
-
"babel-
|
17
|
-
"babel
|
18
|
-
"babel
|
19
|
-
"babel
|
20
|
-
"babel-
|
21
|
-
"babel-
|
15
|
+
"@babel/core": "^7.0.0",
|
16
|
+
"@babel/plugin-proposal-class-properties": "^7.0.0",
|
17
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
|
18
|
+
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
|
19
|
+
"@babel/plugin-transform-destructuring": "^7.0.0",
|
20
|
+
"@babel/plugin-transform-regenerator": "^7.0.0",
|
21
|
+
"@babel/plugin-transform-runtime": "^7.0.0",
|
22
|
+
"@babel/polyfill": "^7.0.0",
|
23
|
+
"@babel/preset-env": "^7.0.0",
|
24
|
+
"@babel/runtime": "^7.0.0",
|
25
|
+
"babel-core": "^7.0.0-bridge",
|
26
|
+
"babel-loader": "^8.0.0",
|
22
27
|
"case-sensitive-paths-webpack-plugin": "^2.1.2",
|
23
|
-
"compression-webpack-plugin": "^1.1.
|
24
|
-
"css-loader": "^0.
|
25
|
-
"file-loader": "^
|
26
|
-
"glob": "^7.1.
|
27
|
-
"js-yaml": "^3.
|
28
|
-
"mini-css-extract-plugin": "^0.4.
|
29
|
-
"node-sass": "^4.
|
28
|
+
"compression-webpack-plugin": "^1.1.12",
|
29
|
+
"css-loader": "^1.0.0",
|
30
|
+
"file-loader": "^2.0.0",
|
31
|
+
"glob": "^7.1.3",
|
32
|
+
"js-yaml": "^3.12.0",
|
33
|
+
"mini-css-extract-plugin": "^0.4.2",
|
34
|
+
"node-sass": "^4.9.3",
|
35
|
+
"optimize-css-assets-webpack-plugin": "^5.0.1",
|
30
36
|
"path-complete-extname": "^1.0.0",
|
31
|
-
"postcss-
|
32
|
-
"postcss-
|
33
|
-
"postcss-
|
34
|
-
"sass-loader": "^
|
35
|
-
"style-loader": "^0.
|
36
|
-
"uglifyjs-webpack-plugin": "^1.
|
37
|
-
"webpack": "^4.
|
38
|
-
"webpack-assets-manifest": "^3.0.
|
39
|
-
"webpack-cli": "^
|
37
|
+
"postcss-import": "^12.0.0",
|
38
|
+
"postcss-loader": "^3.0.0",
|
39
|
+
"postcss-preset-env": "^5.3.0",
|
40
|
+
"sass-loader": "^7.1.0",
|
41
|
+
"style-loader": "^0.23.0",
|
42
|
+
"uglifyjs-webpack-plugin": "^1.3.0",
|
43
|
+
"webpack": "^4.17.1",
|
44
|
+
"webpack-assets-manifest": "^3.0.2",
|
45
|
+
"webpack-cli": "^3.1.0",
|
46
|
+
"webpack-sources": "^1.2.0"
|
40
47
|
},
|
41
48
|
"devDependencies": {
|
42
|
-
"eslint": "^4.
|
43
|
-
"eslint-config-airbnb": "^
|
44
|
-
"eslint-plugin-import": "^2.
|
45
|
-
"eslint-plugin-jsx-a11y": "^6.
|
46
|
-
"eslint-plugin-react": "^7.
|
47
|
-
"jest": "^
|
49
|
+
"eslint": "^5.4.0",
|
50
|
+
"eslint-config-airbnb": "^17.1.0",
|
51
|
+
"eslint-plugin-import": "^2.14.0",
|
52
|
+
"eslint-plugin-jsx-a11y": "^6.1.1",
|
53
|
+
"eslint-plugin-react": "^7.11.1",
|
54
|
+
"jest": "^23.5.0"
|
48
55
|
},
|
49
56
|
"jest": {
|
50
57
|
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
|
@@ -54,7 +61,7 @@
|
|
54
61
|
},
|
55
62
|
"scripts": {
|
56
63
|
"test": "jest",
|
57
|
-
"lint": "eslint
|
64
|
+
"lint": "eslint package/"
|
58
65
|
},
|
59
66
|
"repository": {
|
60
67
|
"type": "git",
|