summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/we/webpack-cli/package.nix
blob: b4b565a6f5837d5de1549e52b2f276262754191c (plain)
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
62
63
64
65
66
67
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchYarnDeps,
  yarnConfigHook,
  yarnBuildHook,
  yarnInstallHook,
  nodejs,
  gitUpdater,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "webpack-cli";
  version = "6.0.1";

  src = fetchFromGitHub {
    owner = "webpack";
    repo = "webpack-cli";
    tag = "webpack-cli@${finalAttrs.version}";
    hash = "sha256-teQWaWWt3rKHEVbj3twt8WQXQO9HuzIBNuvFUfRmxqY=";
  };

  yarnKeepDevDeps = true;

  yarnOfflineCache = fetchYarnDeps {
    yarnLock = finalAttrs.src + "/yarn.lock";
    hash = "sha256-iYyH1/ZyNKq4MqMcCl7y5WvDnuGnRY0sj8hHsQhe7z4=";
  };

  nativeBuildInputs = [
    yarnConfigHook
    yarnBuildHook
    yarnInstallHook
    # Needed for executing package.json scripts
    nodejs
  ];

  preInstall = ''
    cp -r node_modules/* packages/webpack-cli/node_modules/
    cp yarn.lock packages/webpack-cli/yarn.lock
    cd packages/webpack-cli
  '';

  # Removes dangling symlinks that are created as part of the `yarn pack` process.
  # They are not needed at runtime, so it's safe to remove them.
  postInstall = ''
    rm -rf $out/lib/node_modules/webpack-cli/node_modules/{.bin,webpack-cli,create-new-webpack-app,@webpack-cli}
  '';

  postFixup = ''
    mv $out/bin/webpack-cli $out/bin/webpack
  '';

  passthru.updateScript = gitUpdater {
    rev-prefix = "webpack-cli@";
  };

  meta = {
    changelog = "https://github.com/webpack/webpack-cli/blob/webpack-cli%40${finalAttrs.version}/CHANGELOG.md";
    description = "Webpack's Command Line Interface";
    homepage = "https://webpack.js.org/api/cli/";
    license = lib.licenses.mit;
    maintainers = [ ];
    mainProgram = "webpack";
  };
})