Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to elm-live to add Apple Silicon M1 support 🤘🏿 #10

Merged
merged 2 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $ cd frontend && yarn && yarn codegen && yarn start
- [mu-haskell] uses the `schema.graphql` as the single source of truth, using it to generate type level representations of the schema that we can use to implement our server!
- [elm-graphql] also supports code-generation from introspection files, local schema files, and remote servers with introspection enabled _(it usually is)_.
- It's usually better to use a single schema file (like in this repo), with both backend and client code located in the same repo (rather than having duplicate schemas in several repositories - in that case someday they will become inconsistent).
- both [elm-graphql] and [elm-app] can be installed as global dependencies, but we don't consider it a good practice, because it immediately becomes harder to maintain versions.
- both [elm-graphql] and [elm-live] can be installed as global dependencies, but we don't consider it a good practice, because it immediately becomes harder to maintain versions.
- old generated files are removed by [elm-graphql] automatically, we don't need to worry about it.

[elm ci]: https://github.com/kutyel/mu-graphql-example-elm/workflows/Elm%20CI/badge.svg
Expand All @@ -51,7 +51,7 @@ $ cd frontend && yarn && yarn codegen && yarn start
[stack]: https://docs.haskellstack.org/en/stable/README/#how-to-install
[yarn]: https://yarnpkg.com/getting-started/install
[elm-graphql]: https://github.com/dillonkearns/elm-graphql/
[elm-app]: https://github.com/halfzebra/create-elm-app
[elm-live]: https://www.elm-live.com/

## Contributing:

Expand Down
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Distribution
build/

# Dev build artifacts
public/bundle.js

# elm-package generated files
elm-stuff

Expand Down
4 changes: 2 additions & 2 deletions frontend/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.2",
"elm-community/list-extra": "8.2.4",
"elm-community/list-extra": "8.3.0",
"lukewestby/elm-string-interpolate": "1.0.4"
}
},
"test-dependencies": {
"direct": {
"elm-explorations/test": "1.0.0"
"elm-explorations/test": "1.2.2"
},
"indirect": {
"elm/random": "1.0.0"
Expand Down
6 changes: 3 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"description": "Elm client example for our mu-haskell GraphQL server!",
"scripts": {
"codegen": "elm-graphql --schema-file ../library.graphql --base LibraryApi --output src",
"start": "elm-app start"
"start": "elm-live src/Main.elm --dir=public --open --host=0.0.0.0 --port=8080 --pushstate --start-page=index.html -- --output=public/bundle.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the dependencies are much less heavy and the package is better maintained... this line here is terrible DX in my opinion 🤣 Why not make all those arguments the default!? 🤔

},
"author": "higherkindness",
"license": "MIT",
"dependencies": {
"@dillonkearns/elm-graphql": "^4.0.3"
"@dillonkearns/elm-graphql": "^4.2.1"
},
"devDependencies": {
"create-elm-app": "^5.11.0"
"elm-live": "^4.0.2"
}
}
13 changes: 7 additions & 6 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">

<link rel="manifest" href="/manifest.json">
<link rel="shortcut icon" href="/favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/main.css" />

<script type="text/javascript" src="/bundle.js"></script>
<script type="text/javascript" src="/index.js"></script>
<title>Library example</title>
</head>
<body>
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/index.js → frontend/public/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import './main.css'
import { Elm } from './Main.elm'

const app = Elm.Main.init({ node: document.getElementById('root') })
const graphqlWebsocketsUrl = 'ws://localhost:8000'

document.addEventListener('DOMContentLoaded', () => {
const app = Elm.Main.init({ node: document.getElementById('root') })
const graphqlWebsocketsUrl = 'ws://localhost:8000'
let isActive = false

app.ports.subscribeToAllBooks.subscribe((subscriptionString) => {
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/main.css → frontend/public/main.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[data-elm-hot="true"] {
height: inherit;
}

:root {
--main-color-100: rgba(0, 30, 56, 1);
--main-color-60: rgba(0, 30, 56, 0.6);
Expand Down
Loading