From fa2677c7364a555f735784673d1055431eeec8e1 Mon Sep 17 00:00:00 2001 From: Sophie Alpert Date: Fri, 6 Jul 2018 21:15:51 -0700 Subject: [PATCH] Fix flash of unstyled content in dev mode 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 it's more representative of how CSS is loaded in prod, and we don't get a flash of unstyled content in dev. --- assets/webpack.config.js | 6 ++---- config/prod.exs | 2 +- lib/candidate_website/views/layout_view.ex | 6 +++++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/assets/webpack.config.js b/assets/webpack.config.js index 3fa09988..84deaff0 100755 --- a/assets/webpack.config.js +++ b/assets/webpack.config.js @@ -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: { diff --git a/config/prod.exs b/config/prod.exs index 44c79d85..1d44e277 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -28,7 +28,7 @@ config :logger, level: :info config :candidate_website, script_src: ~s(), - css_src: ~s() + css_src: ~s() config :actionkit, base: "${AK_BASE}", diff --git a/lib/candidate_website/views/layout_view.ex b/lib/candidate_website/views/layout_view.ex index dbc3644d..69e238b2 100644 --- a/lib/candidate_website/views/layout_view.ex +++ b/lib/candidate_website/views/layout_view.ex @@ -9,7 +9,11 @@ defmodule CandidateWebsite.LayoutView do ~s() ) - @css_src Application.get_env(:candidate_website, :css_src, "") + @css_src Application.get_env( + :candidate_website, + :css_src, + ~s() + ) def js_script_tag, do: @script_src