Files
codeocean/bin/webpacker
Sebastian Serth 6957452ffc Specify nodes_modules directory for webpack
Also align ./bin/webpacker-dev-server and ./bin/webpacker
2023-02-16 14:23:29 +01:00

19 lines
684 B
Ruby
Executable File

#!/usr/bin/env ruby
require "pathname"
require "bundler/setup"
require "webpacker"
require "webpacker/webpack_runner"
ENV["RAILS_ENV"] ||= "development"
ENV["NODE_ENV"] ||= ENV["RAILS_ENV"]
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)
# We need to specify the path to the node_modules/.bin directory
# The automatic detection of the path doesn't work in all cases, as it could contain an escape sequence.
ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] ||= File.expand_path("../../node_modules/.bin", Pathname.new(__FILE__).realpath)
APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
Webpacker::WebpackRunner.run(ARGV)
end