Skip to content

Commit

Permalink
Fix flash of unstyled content in dev mode
Browse files Browse the repository at this point in the history
In dev mode, we were pulling in styles as part of app.js which comes after all the content. If we move these to a separate bundle that's loaded in <head> it's more representative of how CSS is loaded in prod, and we don't get a flash of unstyled content in dev.
  • Loading branch information
sophiebits committed Jul 7, 2018
1 parent ef246a4 commit fa2677c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 2 additions & 4 deletions assets/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ module.exports = (env) => {
context: __dirname,

entry: {
app: [
"js/app.js",
"stylus/app.styl"
]
styles: ["stylus/app.styl"],
app: ["js/app.js"],
},

output: {
Expand Down
2 changes: 1 addition & 1 deletion config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ config :logger, level: :info

config :candidate_website,
script_src: ~s(<script src="/js/app.js"></script>),
css_src: ~s(<link rel="stylesheet" href="/css/app.css" media="screen,projection" />)
css_src: ~s(<link rel="stylesheet" href="/css/styles.css" media="screen,projection" />)

config :actionkit,
base: "${AK_BASE}",
Expand Down
6 changes: 5 additions & 1 deletion lib/candidate_website/views/layout_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ defmodule CandidateWebsite.LayoutView do
~s(<script src="http://localhost:8080/js/app.js"></script>)
)

@css_src Application.get_env(:candidate_website, :css_src, "")
@css_src Application.get_env(
:candidate_website,
:css_src,
~s(<script src="http://localhost:8080/js/styles.js"></script>)
)

def js_script_tag, do: @script_src

Expand Down

0 comments on commit fa2677c

Please sign in to comment.