Skip to content

Instantly share code, notes, and snippets.

@korutx
Last active May 29, 2020 03:38
Show Gist options
  • Save korutx/27f9b7d8fd2f141002c6922456d73ab9 to your computer and use it in GitHub Desktop.
Save korutx/27f9b7d8fd2f141002c6922456d73ab9 to your computer and use it in GitHub Desktop.
Patch Create Elm App. Allows to configure devserver from elmapp.config.
#!/bin/bash
# die () {
# echo >&2 "$@"
# exit 1
# }
# v=4.2.24
# [ "$v" = "4.2.24" ] ||
# die "Patch solo puede aplicarse a create-elm-app@4.2.24, se encontro $v"
# usage: curl 'https://gist.githubusercontent.com/korutx/27f9b7d8fd2f141002c6922456d73ab9/raw/a1c05d17069acb64893066c725202c79e9c6a4db/patch-configure-devserver.sh' | bash /dev/stdin ~/.nvm/versions/node/v13.9.0/lib/node_modules
nmpath="$1"
paths_js="$nmpath/create-elm-app/config/paths.js"
start_js="$nmpath/create-elm-app/scripts/start.js"
patch1=$(cat << EOF
21c21,22
<
---
> const configureDevServer =
> typeof config.configureDevServer === 'function' ? config.configureDevServer : id;
84c85,86
< configureWebpack
---
> configureWebpack,
> configureDevServer
EOF
)
patch2=$(cat << EOF
174c174
< const serverConfig = createDevServerConfig(
---
> const serverConfig = paths.configureDevServer(createDevServerConfig(
177c177
< );
---
> ), process.env.NODE_ENV);
EOF
)
echo "$patch1" | patch $paths_js
echo "$patch2" | patch $start_js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment