forked from rails/webpacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.rake
28 lines (24 loc) · 896 Bytes
/
compile.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require "webpacker/configuration"
REGEX_MAP = /\A.*\.map\z/
namespace :webpacker do
desc "Compile javascript packs using webpack for production with digests"
task compile: ["webpacker:verify_install", :environment] do
result = `NODE_ENV=production ./bin/webpack`
unless $?.success?
puts JSON.parse(result)["errors"]
exit! $?.exitstatus
end
puts "Compiled digests for all packs in #{Webpacker::Configuration.entry_path}: "
puts JSON.parse(File.read(Webpacker::Configuration.manifest_path))
end
end
# Compile packs after we've compiled all other assets during precompilation
if Rake::Task.task_defined?("assets:precompile")
Rake::Task["assets:precompile"].enhance do
unless Rake::Task.task_defined?("yarn:install")
# For Rails < 5.1
Rake::Task["webpacker:yarn_install"].invoke
end
Rake::Task["webpacker:compile"].invoke
end
end