webpacker 4.0.7 → 5.0.0
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 -1
- data/.rubocop.yml +2 -1
- data/.travis.yml +10 -20
- data/CHANGELOG.md +243 -137
- data/Gemfile +1 -0
- data/Gemfile.lock +84 -62
- data/README.md +52 -149
- data/docs/css.md +15 -4
- data/docs/deployment.md +40 -11
- data/docs/docker.md +33 -14
- data/docs/engines.md +53 -3
- data/docs/es6.md +19 -1
- data/docs/integrations.md +220 -0
- data/docs/troubleshooting.md +37 -9
- data/docs/typescript.md +10 -8
- data/docs/webpack-dev-server.md +1 -1
- data/docs/webpack.md +18 -3
- data/gemfiles/{Gemfile-rails.4.2.x → Gemfile-rails.6.0.x} +1 -1
- data/lib/install/bin/webpack +0 -1
- data/lib/install/bin/webpack-dev-server +0 -1
- data/lib/install/coffee.rb +1 -1
- data/lib/install/config/babel.config.js +10 -10
- data/lib/install/config/webpacker.yml +2 -1
- data/lib/install/elm.rb +1 -1
- data/lib/install/erb.rb +2 -2
- data/lib/install/examples/angular/hello_angular/polyfills.ts +2 -2
- data/lib/install/examples/react/babel.config.js +16 -14
- data/lib/install/examples/svelte/app.svelte +11 -0
- data/lib/install/examples/svelte/hello_svelte.js +20 -0
- data/lib/install/loaders/elm.js +9 -6
- data/lib/install/loaders/svelte.js +9 -0
- data/lib/install/loaders/typescript.js +1 -1
- data/lib/install/svelte.rb +29 -0
- data/lib/install/template.rb +2 -2
- data/lib/install/typescript.rb +1 -1
- data/lib/install/vue.rb +1 -1
- data/lib/tasks/installers.rake +1 -0
- data/lib/tasks/webpacker.rake +2 -0
- data/lib/tasks/webpacker/check_node.rake +14 -7
- data/lib/tasks/webpacker/check_yarn.rake +16 -9
- data/lib/tasks/webpacker/clean.rake +25 -0
- data/lib/tasks/webpacker/clobber.rake +8 -4
- data/lib/tasks/webpacker/compile.rake +2 -10
- data/lib/tasks/webpacker/yarn_install.rake +5 -1
- data/lib/webpacker.rb +9 -1
- data/lib/webpacker/commands.rb +53 -1
- data/lib/webpacker/compiler.rb +15 -8
- data/lib/webpacker/configuration.rb +9 -1
- data/lib/webpacker/dev_server.rb +1 -1
- data/lib/webpacker/dev_server_proxy.rb +2 -8
- data/lib/webpacker/dev_server_runner.rb +4 -4
- data/lib/webpacker/env.rb +1 -1
- data/lib/webpacker/helper.rb +39 -13
- data/lib/webpacker/manifest.rb +4 -4
- data/lib/webpacker/railtie.rb +6 -0
- data/lib/webpacker/version.rb +1 -1
- data/package.json +38 -38
- data/package/__tests__/config.js +0 -23
- data/package/config.js +2 -10
- data/package/config_types/config_list.js +3 -3
- data/package/config_types/config_object.js +1 -1
- data/package/environments/__tests__/base.js +10 -0
- data/package/environments/base.js +14 -3
- data/package/environments/development.js +1 -5
- data/package/environments/production.js +12 -0
- data/package/rules/babel.js +1 -1
- data/package/rules/node_modules.js +2 -2
- data/package/rules/sass.js +3 -2
- data/package/utils/__tests__/get_style_rule.js +9 -0
- data/package/utils/deep_merge.js +5 -5
- data/package/utils/get_style_rule.js +7 -12
- data/package/utils/helpers.js +9 -9
- data/test/command_test.rb +6 -0
- data/test/compiler_test.rb +5 -6
- data/test/configuration_test.rb +36 -27
- data/test/dev_server_test.rb +22 -0
- data/test/helper_test.rb +34 -0
- data/test/manifest_test.rb +37 -6
- data/test/rake_tasks_test.rb +17 -0
- data/test/test_app/app/javascript/packs/multi_entry.css +4 -0
- data/test/test_app/app/javascript/packs/multi_entry.js +4 -0
- data/test/test_app/bin/webpack +0 -1
- data/test/test_app/bin/webpack-dev-server +0 -1
- data/test/test_app/config/webpacker.yml +1 -0
- data/test/test_app/public/packs/manifest.json +3 -0
- data/webpacker.gemspec +5 -3
- data/yarn.lock +2684 -1846
- metadata +48 -12
- data/gemfiles/Gemfile-rails.5.0.x +0 -9
- data/gemfiles/Gemfile-rails.5.1.x +0 -9
@@ -0,0 +1,29 @@
|
|
1
|
+
require "webpacker/configuration"
|
2
|
+
|
3
|
+
say "Copying svelte loader to config/webpack/loaders"
|
4
|
+
copy_file "#{__dir__}/loaders/svelte.js", Rails.root.join("config/webpack/loaders/svelte.js").to_s
|
5
|
+
|
6
|
+
say "Adding svelte loader to config/webpack/environment.js"
|
7
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
|
+
"const svelte = require('./loaders/svelte')\n",
|
9
|
+
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
10
|
+
|
11
|
+
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
12
|
+
"environment.loaders.prepend('svelte', svelte)\n",
|
13
|
+
before: "module.exports"
|
14
|
+
|
15
|
+
say "Copying Svelte example entry file to #{Webpacker.config.source_entry_path}"
|
16
|
+
copy_file "#{__dir__}/examples/svelte/hello_svelte.js",
|
17
|
+
"#{Webpacker.config.source_entry_path}/hello_svelte.js"
|
18
|
+
|
19
|
+
say "Copying Svelte app file to #{Webpacker.config.source_path}"
|
20
|
+
copy_file "#{__dir__}/examples/svelte/app.svelte",
|
21
|
+
"#{Webpacker.config.source_path}/app.svelte"
|
22
|
+
|
23
|
+
say "Installing all Svelte dependencies"
|
24
|
+
run "yarn add svelte svelte-loader"
|
25
|
+
|
26
|
+
say "Updating webpack paths to include .svelte file extension"
|
27
|
+
insert_into_file Webpacker.config.config_path, "- .svelte\n".indent(4), after: /\s+extensions:\n/
|
28
|
+
|
29
|
+
say "Webpacker now supports Svelte 🎉", :green
|
data/lib/install/template.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Install Webpacker
|
2
2
|
copy_file "#{__dir__}/config/webpacker.yml", "config/webpacker.yml"
|
3
3
|
|
4
|
-
|
4
|
+
say "Copying webpack core config"
|
5
5
|
directory "#{__dir__}/config/webpack", "config/webpack"
|
6
6
|
|
7
7
|
say "Copying postcss.config.js to app root directory"
|
@@ -36,7 +36,7 @@ end
|
|
36
36
|
|
37
37
|
if Webpacker::VERSION =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
|
38
38
|
say "Installing all JavaScript dependencies [#{Webpacker::VERSION}]"
|
39
|
-
run "yarn add @rails/webpacker"
|
39
|
+
run "yarn add @rails/webpacker@#{Webpacker::VERSION}"
|
40
40
|
else
|
41
41
|
say "Installing all JavaScript dependencies [from prerelease rails/webpacker]"
|
42
42
|
run "yarn add @rails/webpacker@next"
|
data/lib/install/typescript.rb
CHANGED
@@ -21,7 +21,7 @@ copy_file "#{__dir__}/loaders/typescript.js", Rails.root.join("config/webpack/lo
|
|
21
21
|
say "Adding typescript loader to config/webpack/environment.js"
|
22
22
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
23
23
|
"const typescript = require('./loaders/typescript')\n",
|
24
|
-
after:
|
24
|
+
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
25
25
|
|
26
26
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
27
27
|
"environment.loaders.prepend('typescript', typescript)\n",
|
data/lib/install/vue.rb
CHANGED
@@ -6,7 +6,7 @@ copy_file "#{__dir__}/loaders/vue.js", Rails.root.join("config/webpack/loaders/v
|
|
6
6
|
say "Adding vue loader plugin to config/webpack/environment.js"
|
7
7
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
8
8
|
"const { VueLoaderPlugin } = require('vue-loader')\n",
|
9
|
-
after:
|
9
|
+
after: /require\(('|")@rails\/webpacker\1\);?\n/
|
10
10
|
|
11
11
|
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
|
12
12
|
"environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin())\n",
|
data/lib/tasks/installers.rake
CHANGED
data/lib/tasks/webpacker.rake
CHANGED
@@ -2,6 +2,7 @@ tasks = {
|
|
2
2
|
"webpacker:info" => "Provides information on Webpacker's environment",
|
3
3
|
"webpacker:install" => "Installs and setup webpack with Yarn",
|
4
4
|
"webpacker:compile" => "Compiles webpack bundles based on environment",
|
5
|
+
"webpacker:clean" => "Remove old compiled webpacks",
|
5
6
|
"webpacker:clobber" => "Removes the webpack compiled output directory",
|
6
7
|
"webpacker:check_node" => "Verifies if Node.js is installed",
|
7
8
|
"webpacker:check_yarn" => "Verifies if Yarn is installed",
|
@@ -13,6 +14,7 @@ tasks = {
|
|
13
14
|
"webpacker:install:vue" => "Installs and setup example Vue component",
|
14
15
|
"webpacker:install:angular" => "Installs and setup example Angular component",
|
15
16
|
"webpacker:install:elm" => "Installs and setup example Elm component",
|
17
|
+
"webpacker:install:svelte" => "Installs and setup example Svelte component",
|
16
18
|
"webpacker:install:stimulus" => "Installs and setup example Stimulus component",
|
17
19
|
"webpacker:install:erb" => "Installs Erb loader with an example",
|
18
20
|
"webpacker:install:coffee" => "Installs CoffeeScript loader with an example",
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "semantic_range"
|
1
2
|
namespace :webpacker do
|
2
3
|
desc "Verifies if Node.js is installed"
|
3
4
|
task :check_node do
|
@@ -6,19 +7,25 @@ namespace :webpacker do
|
|
6
7
|
raise Errno::ENOENT if node_version.blank?
|
7
8
|
|
8
9
|
pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
|
9
|
-
|
10
|
+
node_range = JSON.parse(pkg_path.read)["engines"]["node"]
|
11
|
+
is_valid = SemanticRange.satisfies?(node_version, node_range) rescue false
|
12
|
+
semver_major = node_version[/\d+/] rescue nil
|
13
|
+
is_unstable = semver_major.to_i.odd? rescue false
|
10
14
|
|
11
|
-
|
12
|
-
|
15
|
+
if is_unstable
|
16
|
+
$stderr.puts "Warning: you are using an unstable release of Node.js (#{node_version}). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node"
|
17
|
+
end
|
13
18
|
|
14
|
-
unless
|
15
|
-
$stderr.puts "Webpacker requires Node.js #{
|
19
|
+
unless is_valid
|
20
|
+
$stderr.puts "Webpacker requires Node.js \"#{node_range}\" and you are using #{node_version}"
|
16
21
|
$stderr.puts "Please upgrade Node.js https://nodejs.org/en/download/"
|
17
|
-
$stderr.puts "Exiting!"
|
22
|
+
$stderr.puts "Exiting!"
|
23
|
+
exit!
|
18
24
|
end
|
19
25
|
rescue Errno::ENOENT
|
20
26
|
$stderr.puts "Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/"
|
21
|
-
$stderr.puts "Exiting!"
|
27
|
+
$stderr.puts "Exiting!"
|
28
|
+
exit!
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "semantic_range"
|
1
2
|
namespace :webpacker do
|
2
3
|
desc "Verifies if Yarn is installed"
|
3
4
|
task :check_yarn do
|
@@ -6,19 +7,25 @@ namespace :webpacker do
|
|
6
7
|
raise Errno::ENOENT if yarn_version.blank?
|
7
8
|
|
8
9
|
pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
|
9
|
-
|
10
|
+
yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
|
11
|
+
is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
|
12
|
+
is_unsupported = SemanticRange.satisfies?(yarn_version, ">=2.0.0") rescue false
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
unless is_valid
|
15
|
+
$stderr.puts "Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
|
16
|
+
if is_unsupported
|
17
|
+
$stderr.puts "This version of Webpacker does not support Yarn #{yarn_version}. Please downgrade to a supported version of Yarn https://yarnpkg.com/lang/en/docs/install/"
|
18
|
+
$stderr.puts "For information on using Webpacker with Yarn 2.0, see https://github.com/rails/webpacker/issues/2112"
|
19
|
+
else
|
20
|
+
$stderr.puts "Please upgrade Yarn https://yarnpkg.com/lang/en/docs/install/"
|
21
|
+
end
|
22
|
+
$stderr.puts "Exiting!"
|
23
|
+
exit!
|
18
24
|
end
|
19
25
|
rescue Errno::ENOENT
|
20
26
|
$stderr.puts "Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/"
|
21
|
-
$stderr.puts "Exiting!"
|
27
|
+
$stderr.puts "Exiting!"
|
28
|
+
exit!
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$stdout.sync = true
|
2
|
+
|
3
|
+
require "webpacker/configuration"
|
4
|
+
|
5
|
+
namespace :webpacker do
|
6
|
+
desc "Remove old compiled webpacks"
|
7
|
+
task :clean, [:keep, :age] => ["webpacker:verify_install", :environment] do |_, args|
|
8
|
+
Webpacker.ensure_log_goes_to_stdout do
|
9
|
+
Webpacker.clean(Integer(args.keep || 2), Integer(args.age || 3600))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
skip_webpacker_clean = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
|
15
|
+
|
16
|
+
unless skip_webpacker_clean
|
17
|
+
# Run clean if the assets:clean is run
|
18
|
+
if Rake::Task.task_defined?("assets:clean")
|
19
|
+
Rake::Task["assets:clean"].enhance do
|
20
|
+
Rake::Task["webpacker:clean"].invoke
|
21
|
+
end
|
22
|
+
else
|
23
|
+
Rake::Task.define_task("assets:clean" => "webpacker:clean")
|
24
|
+
end
|
25
|
+
end
|
@@ -8,9 +8,13 @@ namespace :webpacker do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
skip_webpacker_clobber = %w(no false n f).include?(ENV["WEBPACKER_PRECOMPILE"])
|
12
|
+
|
13
|
+
unless skip_webpacker_clobber
|
14
|
+
# Run clobber if the assets:clobber is run
|
15
|
+
if Rake::Task.task_defined?("assets:clobber")
|
16
|
+
Rake::Task["assets:clobber"].enhance do
|
17
|
+
Rake::Task["webpacker:clobber"].invoke
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
@@ -1,13 +1,5 @@
|
|
1
1
|
$stdout.sync = true
|
2
2
|
|
3
|
-
def ensure_log_goes_to_stdout
|
4
|
-
old_logger = Webpacker.logger
|
5
|
-
Webpacker.logger = ActiveSupport::Logger.new(STDOUT)
|
6
|
-
yield
|
7
|
-
ensure
|
8
|
-
Webpacker.logger = old_logger
|
9
|
-
end
|
10
|
-
|
11
3
|
def yarn_install_available?
|
12
4
|
rails_major = Rails::VERSION::MAJOR
|
13
5
|
rails_minor = Rails::VERSION::MINOR
|
@@ -26,8 +18,8 @@ end
|
|
26
18
|
namespace :webpacker do
|
27
19
|
desc "Compile JavaScript packs using webpack for production with digests"
|
28
20
|
task compile: ["webpacker:verify_install", :environment] do
|
29
|
-
Webpacker.with_node_env("production") do
|
30
|
-
ensure_log_goes_to_stdout do
|
21
|
+
Webpacker.with_node_env(ENV.fetch("NODE_ENV", "production")) do
|
22
|
+
Webpacker.ensure_log_goes_to_stdout do
|
31
23
|
if Webpacker.compile
|
32
24
|
# Successful compilation!
|
33
25
|
else
|
@@ -1,6 +1,10 @@
|
|
1
1
|
namespace :webpacker do
|
2
2
|
desc "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
3
3
|
task :yarn_install do
|
4
|
-
|
4
|
+
valid_node_envs = %w[test development production]
|
5
|
+
node_env = ENV.fetch("NODE_ENV") do
|
6
|
+
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
|
7
|
+
end
|
8
|
+
system({ "NODE_ENV" => node_env }, "yarn install --no-progress --frozen-lockfile")
|
5
9
|
end
|
6
10
|
end
|
data/lib/webpacker.rb
CHANGED
@@ -22,9 +22,17 @@ module Webpacker
|
|
22
22
|
ENV["NODE_ENV"] = original
|
23
23
|
end
|
24
24
|
|
25
|
+
def ensure_log_goes_to_stdout
|
26
|
+
old_logger = Webpacker.logger
|
27
|
+
Webpacker.logger = ActiveSupport::Logger.new(STDOUT)
|
28
|
+
yield
|
29
|
+
ensure
|
30
|
+
Webpacker.logger = old_logger
|
31
|
+
end
|
32
|
+
|
25
33
|
delegate :logger, :logger=, :env, to: :instance
|
26
34
|
delegate :config, :compiler, :manifest, :commands, :dev_server, to: :instance
|
27
|
-
delegate :bootstrap, :clobber, :compile, to: :commands
|
35
|
+
delegate :bootstrap, :clean, :clobber, :compile, to: :commands
|
28
36
|
end
|
29
37
|
|
30
38
|
require "webpacker/instance"
|
data/lib/webpacker/commands.rb
CHANGED
@@ -1,10 +1,43 @@
|
|
1
1
|
class Webpacker::Commands
|
2
|
-
delegate :config, :compiler, :manifest, to: :@webpacker
|
2
|
+
delegate :config, :compiler, :manifest, :logger, to: :@webpacker
|
3
3
|
|
4
4
|
def initialize(webpacker)
|
5
5
|
@webpacker = webpacker
|
6
6
|
end
|
7
7
|
|
8
|
+
# Cleanup old assets in the compile directory. By default it will
|
9
|
+
# keep the latest version, 2 backups created within the past hour.
|
10
|
+
#
|
11
|
+
# Examples
|
12
|
+
#
|
13
|
+
# To force only 1 backup to be kept, set count=1 and age=0.
|
14
|
+
#
|
15
|
+
# To only keep files created within the last 10 minutes, set count=0 and
|
16
|
+
# age=600.
|
17
|
+
#
|
18
|
+
def clean(count = 2, age = 3600)
|
19
|
+
if config.public_output_path.exist? && config.public_manifest_path.exist?
|
20
|
+
versions
|
21
|
+
.sort
|
22
|
+
.reverse
|
23
|
+
.each_with_index
|
24
|
+
.drop_while do |(mtime, _), index|
|
25
|
+
max_age = [0, Time.now - Time.at(mtime)].max
|
26
|
+
max_age < age && index < count
|
27
|
+
end
|
28
|
+
.each do |(_, files), index|
|
29
|
+
files.each do |file|
|
30
|
+
if File.file?(file)
|
31
|
+
File.delete(file)
|
32
|
+
logger.info "Removed #{file}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
8
41
|
def clobber
|
9
42
|
config.public_output_path.rmtree if config.public_output_path.exist?
|
10
43
|
config.cache_path.rmtree if config.cache_path.exist?
|
@@ -19,4 +52,23 @@ class Webpacker::Commands
|
|
19
52
|
manifest.refresh if success
|
20
53
|
end
|
21
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def versions
|
58
|
+
all_files = Dir.glob("#{config.public_output_path}/**/*")
|
59
|
+
manifest_config = Dir.glob("#{config.public_manifest_path}*")
|
60
|
+
|
61
|
+
packs = all_files - manifest_config - current_version
|
62
|
+
packs.reject { |file| File.directory?(file) }.group_by { |file| File.mtime(file).utc.to_i }
|
63
|
+
end
|
64
|
+
|
65
|
+
def current_version
|
66
|
+
packs = manifest.refresh.values.map do |value|
|
67
|
+
next if value.is_a?(Hash)
|
68
|
+
|
69
|
+
File.join(config.root_path, "public", "#{value}*")
|
70
|
+
end.compact
|
71
|
+
|
72
|
+
Dir.glob(packs).uniq
|
73
|
+
end
|
22
74
|
end
|
data/lib/webpacker/compiler.rb
CHANGED
@@ -19,9 +19,15 @@ class Webpacker::Compiler
|
|
19
19
|
def compile
|
20
20
|
if stale?
|
21
21
|
run_webpack.tap do |success|
|
22
|
-
|
22
|
+
# We used to only record the digest on success
|
23
|
+
# However, the output file is still written on error, (at least with ts-loader), meaning that the
|
24
|
+
# digest should still be updated. If it's not, you can end up in a situation where a recompile doesn't
|
25
|
+
# take place when it should.
|
26
|
+
# See https://github.com/rails/webpacker/issues/2113
|
27
|
+
record_compilation_digest
|
23
28
|
end
|
24
29
|
else
|
30
|
+
logger.info "Everything's up-to-date. Nothing to do"
|
25
31
|
true
|
26
32
|
end
|
27
33
|
end
|
@@ -56,7 +62,7 @@ class Webpacker::Compiler
|
|
56
62
|
end
|
57
63
|
|
58
64
|
def run_webpack
|
59
|
-
logger.info "Compiling
|
65
|
+
logger.info "Compiling..."
|
60
66
|
|
61
67
|
stdout, stderr, status = Open3.capture3(
|
62
68
|
webpack_env,
|
@@ -67,12 +73,13 @@ class Webpacker::Compiler
|
|
67
73
|
if status.success?
|
68
74
|
logger.info "Compiled all packs in #{config.public_output_path}"
|
69
75
|
logger.error "#{stderr}" unless stderr.empty?
|
70
|
-
else
|
71
|
-
logger.error "Compilation failed:\n#{stderr}"
|
72
|
-
end
|
73
76
|
|
74
|
-
|
75
|
-
|
77
|
+
if config.webpack_compile_output?
|
78
|
+
logger.info stdout
|
79
|
+
end
|
80
|
+
else
|
81
|
+
non_empty_streams = [stdout, stderr].delete_if(&:empty?)
|
82
|
+
logger.error "Compilation failed:\n#{non_empty_streams.join("\n\n")}"
|
76
83
|
end
|
77
84
|
|
78
85
|
status.success?
|
@@ -81,7 +88,7 @@ class Webpacker::Compiler
|
|
81
88
|
def default_watched_paths
|
82
89
|
[
|
83
90
|
*config.resolved_paths_globbed,
|
84
|
-
|
91
|
+
config.source_path_globbed,
|
85
92
|
"yarn.lock", "package.json",
|
86
93
|
"config/webpack/**/*"
|
87
94
|
].freeze
|
@@ -23,12 +23,16 @@ class Webpacker::Configuration
|
|
23
23
|
root_path.join(fetch(:source_path))
|
24
24
|
end
|
25
25
|
|
26
|
+
def source_path_globbed
|
27
|
+
globbed_path_with_extensions(source_path.relative_path_from(root_path))
|
28
|
+
end
|
29
|
+
|
26
30
|
def resolved_paths
|
27
31
|
fetch(:resolved_paths)
|
28
32
|
end
|
29
33
|
|
30
34
|
def resolved_paths_globbed
|
31
|
-
resolved_paths.map { |p|
|
35
|
+
resolved_paths.map { |p| globbed_path_with_extensions(p) }
|
32
36
|
end
|
33
37
|
|
34
38
|
def source_entry_path
|
@@ -102,4 +106,8 @@ class Webpacker::Configuration
|
|
102
106
|
@defaults ||= \
|
103
107
|
HashWithIndifferentAccess.new(YAML.load_file(File.expand_path("../../install/config/webpacker.yml", __FILE__))[env])
|
104
108
|
end
|
109
|
+
|
110
|
+
def globbed_path_with_extensions(path)
|
111
|
+
"#{path}/**/*{#{extensions.join(',')}}"
|
112
|
+
end
|
105
113
|
end
|