54 lines
1.8 KiB
Ruby
54 lines
1.8 KiB
Ruby
require "language/node"
|
|
require "json"
|
|
|
|
class Webpack < Formula
|
|
desc "Bundler for JavaScript and friends"
|
|
homepage "https://webpack.js.org/"
|
|
url "https://registry.npmjs.org/webpack/-/webpack-4.16.1.tgz"
|
|
sha256 "19b9135f4071e438a59c39e83a44c0cb1922cba4b6e90e19063c317663495929"
|
|
head "https://github.com/webpack/webpack.git"
|
|
|
|
bottle do
|
|
sha256 "2bed760a548508b94958f36fda9f4b4e45edb570d12317418d3037fa66282949" => :high_sierra
|
|
sha256 "12e7cc90589f1e6e39361afd3e75773a160e0e9cf4c42cf222ab01bc7e107c5f" => :sierra
|
|
sha256 "9c4209ecfca066166be5e6bceaa5165d521283beb8a122895f4f70e604fb187a" => :el_capitan
|
|
end
|
|
|
|
depends_on "node"
|
|
|
|
resource "webpack-cli" do
|
|
url "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.0.8.tgz"
|
|
sha256 "bad0d3c4a793e865217343aa60395cb4fa6309fcca1117554811fba723a8bb64"
|
|
end
|
|
|
|
def install
|
|
(buildpath/"node_modules/webpack").install Dir["*"]
|
|
buildpath.install resource("webpack-cli")
|
|
|
|
# declare webpack as a bundledDependency of webpack-cli
|
|
pkg_json = JSON.parse(IO.read("package.json"))
|
|
pkg_json["dependencies"]["webpack"] = version
|
|
pkg_json["bundledDependencies"] = ["webpack"]
|
|
IO.write("package.json", JSON.pretty_generate(pkg_json))
|
|
|
|
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
|
|
|
|
bin.install_symlink libexec/"bin/webpack-cli"
|
|
bin.install_symlink libexec/"bin/webpack-cli" => "webpack"
|
|
end
|
|
|
|
test do
|
|
(testpath/"index.js").write <<~EOS
|
|
function component () {
|
|
var element = document.createElement('div');
|
|
element.innerHTML = 'Hello' + ' ' + 'webpack';
|
|
return element;
|
|
}
|
|
|
|
document.body.appendChild(component());
|
|
EOS
|
|
|
|
system bin/"webpack", "index.js", "--output=bundle.js"
|
|
assert_predicate testpath/"bundle.js", :exist?, "bundle.js was not generated"
|
|
end
|
|
end
|