-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
/
Copy pathwebpack.rb
61 lines (49 loc) · 2.37 KB
/
webpack.rb
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require "json"
class Webpack < Formula
desc "Bundler for JavaScript and friends"
homepage "https://webpack.js.org/"
url "https://registry.npmjs.org/webpack/-/webpack-5.98.0.tgz"
sha256 "abd3a2b6e5b0a9bd92ff8d89faf11ae0cc29697768e239936cf2f6b613ae9cff"
license "MIT"
head "https://github.com/webpack/webpack.git", branch: "main"
bottle do
sha256 cellar: :any_skip_relocation, arm64_sequoia: "2bb12aec50e5582fd19fcaeac75d842fa903d6d231ab25c1b05edfc00f4f8711"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "2bb12aec50e5582fd19fcaeac75d842fa903d6d231ab25c1b05edfc00f4f8711"
sha256 cellar: :any_skip_relocation, arm64_ventura: "2bb12aec50e5582fd19fcaeac75d842fa903d6d231ab25c1b05edfc00f4f8711"
sha256 cellar: :any_skip_relocation, sonoma: "ae5fbd970bf08391801be99e67b0ef1d819d0aef8a03490ea6e296b05dbe4967"
sha256 cellar: :any_skip_relocation, ventura: "ae5fbd970bf08391801be99e67b0ef1d819d0aef8a03490ea6e296b05dbe4967"
sha256 cellar: :any_skip_relocation, x86_64_linux: "2bb12aec50e5582fd19fcaeac75d842fa903d6d231ab25c1b05edfc00f4f8711"
end
depends_on "node"
resource "webpack-cli" do
url "https://registry.npmjs.org/webpack-cli/-/webpack-cli-6.0.1.tgz"
sha256 "f407788079854b0d48fb750da496c59cf00762dce3731520a4b375a377dec183"
end
def install
(buildpath/"node_modules/webpack").install Dir["*"]
buildpath.install resource("webpack-cli")
cd buildpath/"node_modules/webpack" do
system "npm", "install", *std_npm_args(prefix: false), "--force"
end
# declare webpack as a bundledDependency of webpack-cli
pkg_json = JSON.parse(File.read("package.json"))
pkg_json["dependencies"]["webpack"] = version
pkg_json["bundleDependencies"] = ["webpack"]
File.write("package.json", JSON.pretty_generate(pkg_json))
system "npm", "install", *std_npm_args
bin.install_symlink libexec.glob("bin/*")
bin.install_symlink libexec/"bin/webpack-cli" => "webpack"
end
test do
(testpath/"index.js").write <<~JS
function component() {
const element = document.createElement('div');
element.innerHTML = 'Hello webpack';
return element;
}
document.body.appendChild(component());
JS
system bin/"webpack", "bundle", "--mode=production", testpath/"index.js"
assert_match 'const e=document.createElement("div");', (testpath/"dist/main.js").read
end
end