Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Relax assumptions in webpack:compile rake tasks #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/tasks/webpack.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ namespace :webpack do
task compile: :environment do
ENV["TARGET"] = 'production' # TODO: Deprecated, use NODE_ENV instead
ENV["NODE_ENV"] = 'production'
webpack_bin = ::Rails.root.join(::Rails.configuration.webpack.binary)
webpack_bin = ::Rails.configuration.webpack.binary
config_file = ::Rails.root.join(::Rails.configuration.webpack.config_file)

unless File.exist?(webpack_bin)
raise "Can't find our webpack executable at #{webpack_bin} - have you run `npm install`?"
which_webpack_result = `which #{webpack_bin}`.chomp
which_webpack_status = $CHILD_STATUS
unless which_webpack_status.success? && which_webpack_result != ""
warn <<-EOF.strip_heredoc
Running `which #{webpack_bin}` returned status code #{which_webpack_status.to_i} with output:
#{which_webpack_status}
EOF
raise "Can't find webpack executable at #{webpack_bin.inspect}. Have you run `npm install`?"
end

unless File.exist?(config_file)
raise "Can't find our webpack config file at #{config_file}"
raise "Can't find webpack config file at #{config_file}"
end

sh "#{webpack_bin} --config #{config_file} --bail"
Expand Down