1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchYarnDeps,
6 yarnConfigHook,
7 yarnBuildHook,
8 yarnInstallHook,
9 nodejs,
10 gitUpdater,
11}:
12
13stdenv.mkDerivation (finalAttrs: {
14 pname = "webpack-cli";
15 version = "6.0.1";
16
17 src = fetchFromGitHub {
18 owner = "webpack";
19 repo = "webpack-cli";
20 tag = "webpack-cli@${finalAttrs.version}";
21 hash = "sha256-teQWaWWt3rKHEVbj3twt8WQXQO9HuzIBNuvFUfRmxqY=";
22 };
23
24 yarnKeepDevDeps = true;
25
26 yarnOfflineCache = fetchYarnDeps {
27 yarnLock = finalAttrs.src + "/yarn.lock";
28 hash = "sha256-iYyH1/ZyNKq4MqMcCl7y5WvDnuGnRY0sj8hHsQhe7z4=";
29 };
30
31 nativeBuildInputs = [
32 yarnConfigHook
33 yarnBuildHook
34 yarnInstallHook
35 # Needed for executing package.json scripts
36 nodejs
37 ];
38
39 preInstall = ''
40 cp -r node_modules/* packages/webpack-cli/node_modules/
41 cp yarn.lock packages/webpack-cli/yarn.lock
42 cd packages/webpack-cli
43 '';
44
45 # Removes dangling symlinks that are created as part of the `yarn pack` process.
46 # They are not needed at runtime, so it's safe to remove them.
47 postInstall = ''
48 rm -rf $out/lib/node_modules/webpack-cli/node_modules/{.bin,webpack-cli,create-new-webpack-app,@webpack-cli}
49 '';
50
51 postFixup = ''
52 mv $out/bin/webpack-cli $out/bin/webpack
53 '';
54
55 passthru.updateScript = gitUpdater {
56 rev-prefix = "webpack-cli@";
57 };
58
59 meta = {
60 changelog = "https://github.com/webpack/webpack-cli/blob/webpack-cli%2540${finalAttrs.version}/CHANGELOG.md";
61 description = "Webpack's Command Line Interface";
62 homepage = "https://webpack.js.org/api/cli/";
63 license = lib.licenses.mit;
64 maintainers = with lib.maintainers; [ pyrox0 ];
65 mainProgram = "webpack";
66 };
67})