Skip to content

Commit

Permalink
Merge pull request #62 from dwyl/Update-to-Phoenix-1.6-issue-#61
Browse files Browse the repository at this point in the history
Update to phoenix 1.6 issue #61 [Part 2]
  • Loading branch information
nelsonic authored Oct 16, 2021
2 parents a428e4b + f12eaeb commit 0731092
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: MIX_ENV=prod mix ecto.migrate && mix phx.server
web: MIX_ENV=prod mix ecto.migrate && mix assets.deploy && mix phx.server
5 changes: 0 additions & 5 deletions assets/.babelrc

This file was deleted.

51 changes: 51 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* This file is for your main application css. */
@import "./phoenix.css";

html {
height: 100%;
box-sizing: border-box;
}

*,
*:before,
*:after {
box-sizing: inherit;
}

body {
position: relative;
margin: 0;
padding-bottom: 1rem;
min-height: 100%;
font-family: "Helvetica Neue", Arial, sans-serif;
}

/* Alerts and form errors */
.alert {
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
}
.alert-info {
color: #31708f;
background-color: #d9edf7;
border-color: #bce8f1;
}
.alert-warning {
color: #8a6d3b;
background-color: #fcf8e3;
border-color: #faebcc;
}
.alert-danger {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
.alert p {
margin-bottom: 0;
}
.alert:empty {
display: none;
}

3 changes: 0 additions & 3 deletions assets/css/app.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* This file is for your main application css. */
@import "./phoenix.css";

html {
height: 100%;
box-sizing: border-box;
Expand Down
3 changes: 2 additions & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// We need to import the CSS so that webpack will load it.
// The MiniCssExtractPlugin is used to separate it out into
// its own CSS file.
import "../css/app.scss"
import "../css/phoenix.css"
import "../css/app.css"

// webpack automatically bundles all modules in your
// entry points. Those entry points can be configured
Expand Down
27 changes: 0 additions & 27 deletions assets/package.json

This file was deleted.

51 changes: 0 additions & 51 deletions assets/webpack.config.js

This file was deleted.

8 changes: 7 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ config :phoenix, :json_library, Jason
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs"

config :esbuild, :version, "0.13.4"
config :esbuild,
version: "0.13.4",
default: [
args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/assets),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
9 changes: 2 additions & 7 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ config :chat, ChatWeb.Endpoint,
code_reloader: true,
check_origin: false,
watchers: [
node: [
"node_modules/webpack/bin/webpack.js",
"--mode",
"development",
"--watch-stdin",
cd: Path.expand("../assets", __DIR__)
]
# Start the esbuild watcher by calling Esbuild.install_and_run(:default, args)
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]}
]

# ## SSL Support
Expand Down
3 changes: 2 additions & 1 deletion coveralls.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"lib/chat/application.ex",
"lib/chat_web/router.ex",
"lib/chat_web/views/error_helpers.ex",
"lib/chat_web/telemetry.ex"
"lib/chat_web/telemetry.ex",
"lib/chat_web/channels/user_socket.ex"
]
}
17 changes: 9 additions & 8 deletions lib/chat_web/channels/room_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ defmodule ChatWeb.RoomChannel do
use ChatWeb, :channel

@impl true
def join("room:lobby", payload, socket) do
if authorized?(payload) do
def join("room:lobby", _payload, socket) do
# if authorized?(payload) do
send(self(), :after_join)
{:ok, socket}
else
{:error, %{reason: "unauthorized"}}
end
# else
# {:error, %{reason: "unauthorized"}}
# end
end

def handle_in("ping", payload, socket) do
Expand All @@ -25,9 +25,10 @@ defmodule ChatWeb.RoomChannel do
end

# Add authorization logic here as required.
defp authorized?(_payload) do
true
end
# Auth coming soon via: https://github.com/dwyl/phoenix-chat-example/issues/54
# defp authorized?(_payload) do
# true
# end

@impl true
def handle_info(:after_join, socket) do
Expand Down
2 changes: 1 addition & 1 deletion lib/chat_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule ChatWeb.Endpoint do
at: "/",
from: :chat,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
only: ~w(assets fonts images favicon.ico robots.txt)

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
Expand Down
4 changes: 2 additions & 2 deletions lib/chat_web/templates/layout/app.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Chat · Phoenix Framework</title>
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
<script defer type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/assets/app.css") %>"/>
<script defer type="text/javascript" src="<%= Routes.static_path(@conn, "/assets/app.js") %>"></script>
</head>
<body>
<header>
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ defmodule Chat.Mixfile do
"ecto.reset": ["ecto.drop", "ecto.setup"],
test: ["ecto.create --quiet", "ecto.migrate", "test"],
cover: ["coveralls.json"],
"cover.html": ["coveralls.html"]
"cover.html": ["coveralls.html"],
"assets.deploy": ["esbuild default --minify", "phx.digest"]
]
end
end

0 comments on commit 0731092

Please sign in to comment.