mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-31 00:37:45 +02:00
prelim work on vite reload
This commit is contained in:
parent
ac908d2efd
commit
f591939ccd
8 changed files with 32 additions and 10 deletions
|
@ -8,3 +8,6 @@
|
||||||
// Our code
|
// Our code
|
||||||
import './ujs';
|
import './ujs';
|
||||||
import './when-ready';
|
import './when-ready';
|
||||||
|
|
||||||
|
// Fallback on the dark theme for now
|
||||||
|
import '../css/themes/dark.scss';
|
||||||
|
|
|
@ -17,10 +17,10 @@ config :philomena, PhilomenaWeb.Endpoint,
|
||||||
watchers: [
|
watchers: [
|
||||||
node: [
|
node: [
|
||||||
"node_modules/vite/bin/vite.js",
|
"node_modules/vite/bin/vite.js",
|
||||||
"build",
|
|
||||||
"--mode",
|
"--mode",
|
||||||
"development",
|
"development",
|
||||||
"--watch",
|
"--host",
|
||||||
|
"0.0.0.0",
|
||||||
"--config",
|
"--config",
|
||||||
"vite.config.ts",
|
"vite.config.ts",
|
||||||
cd: Path.expand("../assets", __DIR__)
|
cd: Path.expand("../assets", __DIR__)
|
||||||
|
|
|
@ -137,6 +137,9 @@ if config_env() == :prod do
|
||||||
|
|
||||||
# Do not relax CSP in production
|
# Do not relax CSP in production
|
||||||
config :philomena, csp_relaxed: false
|
config :philomena, csp_relaxed: false
|
||||||
|
|
||||||
|
# Disable Vite HMR in prod
|
||||||
|
config :philomena, vite_reload: false
|
||||||
else
|
else
|
||||||
# Don't send email in development
|
# Don't send email in development
|
||||||
config :philomena, Philomena.Mailer, adapter: Bamboo.LocalAdapter
|
config :philomena, Philomena.Mailer, adapter: Bamboo.LocalAdapter
|
||||||
|
@ -146,4 +149,7 @@ else
|
||||||
|
|
||||||
# Relax CSP rules in development and test servers
|
# Relax CSP rules in development and test servers
|
||||||
config :philomena, csp_relaxed: true
|
config :philomena, csp_relaxed: true
|
||||||
|
|
||||||
|
# Enable Vite HMR
|
||||||
|
config :philomena, vite_reload: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,6 +48,8 @@ services:
|
||||||
- postgres
|
- postgres
|
||||||
- elasticsearch
|
- elasticsearch
|
||||||
- redis
|
- redis
|
||||||
|
ports:
|
||||||
|
- '5173:5173'
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16.2-alpine
|
image: postgres:16.2-alpine
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM elixir:1.16.1-alpine
|
FROM elixir:1.16.2-alpine
|
||||||
|
|
||||||
ADD https://api.github.com/repos/philomena-dev/FFmpeg/git/refs/heads/release/6.1 /tmp/ffmpeg_version.json
|
ADD https://api.github.com/repos/philomena-dev/FFmpeg/git/refs/heads/release/6.1 /tmp/ffmpeg_version.json
|
||||||
RUN (echo "https://github.com/philomena-dev/prebuilt-ffmpeg/raw/master"; cat /etc/apk/repositories) > /tmp/repositories \
|
RUN (echo "https://github.com/philomena-dev/prebuilt-ffmpeg/raw/master"; cat /etc/apk/repositories) > /tmp/repositories \
|
||||||
|
@ -24,4 +24,5 @@ COPY docker/app/run-test /usr/local/bin/run-test
|
||||||
COPY docker/app/safe-rsvg-convert /usr/local/bin/safe-rsvg-convert
|
COPY docker/app/safe-rsvg-convert /usr/local/bin/safe-rsvg-convert
|
||||||
COPY docker/app/purge-cache /usr/local/bin/purge-cache
|
COPY docker/app/purge-cache /usr/local/bin/purge-cache
|
||||||
ENV PATH=$PATH:/root/.cargo/bin
|
ENV PATH=$PATH:/root/.cargo/bin
|
||||||
|
EXPOSE 5173
|
||||||
CMD run-development
|
CMD run-development
|
||||||
|
|
|
@ -24,8 +24,9 @@ defmodule PhilomenaWeb.ContentSecurityPolicyPlug do
|
||||||
|
|
||||||
csp_config = [
|
csp_config = [
|
||||||
{:default_src, ["'self'"]},
|
{:default_src, ["'self'"]},
|
||||||
{:script_src, ["'self'" | script_src]},
|
{:script_src, ["'self' localhost:5173" | script_src]},
|
||||||
{:style_src, ["'self'" | style_src]},
|
{:connect_src, ["'self' ws://localhost:5173 localhost:5173"]},
|
||||||
|
{:style_src, ["'self' 'unsafe-inline'" | style_src]},
|
||||||
{:object_src, ["'none'"]},
|
{:object_src, ["'none'"]},
|
||||||
{:frame_ancestors, ["'none'"]},
|
{:frame_ancestors, ["'none'"]},
|
||||||
{:frame_src, frame_src || ["'none'"]},
|
{:frame_src, frame_src || ["'none'"]},
|
||||||
|
|
|
@ -10,18 +10,23 @@ html lang="en"
|
||||||
' - Derpibooru
|
' - Derpibooru
|
||||||
- else
|
- else
|
||||||
' Derpibooru
|
' Derpibooru
|
||||||
link rel="stylesheet" href=stylesheet_path(@conn, @current_user)
|
|
||||||
= if is_nil(@current_user) do
|
|
||||||
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)"
|
|
||||||
link rel="icon" href="/favicon.ico" type="image/x-icon"
|
link rel="icon" href="/favicon.ico" type="image/x-icon"
|
||||||
link rel="icon" href="/favicon.svg" type="image/svg+xml"
|
link rel="icon" href="/favicon.svg" type="image/svg+xml"
|
||||||
meta name="generator" content="philomena"
|
meta name="generator" content="philomena"
|
||||||
meta name="theme-color" content="#618fc3"
|
meta name="theme-color" content="#618fc3"
|
||||||
meta name="format-detection" content="telephone=no"
|
meta name="format-detection" content="telephone=no"
|
||||||
= csrf_meta_tag()
|
= csrf_meta_tag()
|
||||||
script type="module" src=Routes.static_path(@conn, "/js/app.js") async="async"
|
|
||||||
|
= if vite_reload?() do
|
||||||
|
script type="module" src="http://localhost:5173/@vite/client"
|
||||||
|
script type="module" src="http://localhost:5173/js/app.js"
|
||||||
|
- else
|
||||||
|
link rel="stylesheet" href=stylesheet_path(@conn, @current_user)
|
||||||
|
= if is_nil(@current_user) do
|
||||||
|
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)"
|
||||||
|
script type="text/javascript" src=Routes.static_path(@conn, "/js/app.js") async="async"
|
||||||
= render PhilomenaWeb.LayoutView, "_opengraph.html", assigns
|
= render PhilomenaWeb.LayoutView, "_opengraph.html", assigns
|
||||||
body data-theme=theme_name(@current_user)
|
body data-theme=theme_name(@current_user) data-vite-reload=to_string(vite_reload?())
|
||||||
= render PhilomenaWeb.LayoutView, "_burger.html", assigns
|
= render PhilomenaWeb.LayoutView, "_burger.html", assigns
|
||||||
#container class=container_class(@current_user)
|
#container class=container_class(@current_user)
|
||||||
= render PhilomenaWeb.LayoutView, "_header.html", assigns
|
= render PhilomenaWeb.LayoutView, "_header.html", assigns
|
||||||
|
|
|
@ -22,6 +22,10 @@ defmodule PhilomenaWeb.LayoutView do
|
||||||
Application.get_env(:philomena, :cdn_host)
|
Application.get_env(:philomena, :cdn_host)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def vite_reload? do
|
||||||
|
Application.get_env(:philomena, :vite_reload)
|
||||||
|
end
|
||||||
|
|
||||||
defp ignored_tag_list(nil), do: []
|
defp ignored_tag_list(nil), do: []
|
||||||
defp ignored_tag_list([]), do: []
|
defp ignored_tag_list([]), do: []
|
||||||
defp ignored_tag_list([{tag, _body, _dnp_entries}]), do: [tag.id]
|
defp ignored_tag_list([{tag, _body, _dnp_entries}]), do: [tag.id]
|
||||||
|
|
Loading…
Add table
Reference in a new issue