Keep static files outside priv (#602)
* Keep static files outside priv * Override generated assets on the CI
4
.github/workflows/deploy.yaml
vendored
|
@ -38,6 +38,8 @@ jobs:
|
|||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
- name: Clean generated assets
|
||||
run: rm -rf static/{js,css}
|
||||
- name: Install npm dependencies
|
||||
run: npm ci --prefix assets
|
||||
- name: Build assets
|
||||
|
@ -46,7 +48,7 @@ jobs:
|
|||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Update assets
|
||||
file_pattern: priv/static
|
||||
file_pattern: static
|
||||
docker:
|
||||
# The assets job may push new commit, so we wait for it
|
||||
needs: assets
|
||||
|
|
|
@ -25,7 +25,7 @@ RUN mix do deps.get, deps.compile
|
|||
|
||||
# Compile and build the release
|
||||
COPY rel rel
|
||||
COPY priv priv
|
||||
COPY static static
|
||||
COPY lib lib
|
||||
# We need README.md during compilation
|
||||
# (look for @external_resource "README.md")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1><img src="https://github.com/livebook-dev/livebook/raw/main/priv/static/images/logo-with-text.png" alt="Livebook" width="400"></h1>
|
||||
<h1><img src="https://github.com/livebook-dev/livebook/raw/main/static/images/logo-with-text.png" alt="Livebook" width="400"></h1>
|
||||
|
||||
[![Hex.pm](https://img.shields.io/hexpm/v/livebook)](https://hex.pm/packages/livebook)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = (env, options) => {
|
|||
filename: "[name].js",
|
||||
path: path.resolve(
|
||||
__dirname,
|
||||
devMode ? "../tmp/static_dev/js" : "../priv/static/js"
|
||||
devMode ? "../tmp/static_dev/js" : "../static/js"
|
||||
),
|
||||
publicPath: "/js/",
|
||||
},
|
||||
|
|
|
@ -16,13 +16,13 @@ defmodule LivebookWeb.Endpoint do
|
|||
# The WebSocket connection is already protected from CSWSH by using CSRF token.
|
||||
websocket: [check_origin: false, connect_info: [:user_agent, session: @session_options]]
|
||||
|
||||
# We use Escript for distributing Livebook, so we don't
|
||||
# have access to the files in priv/static at runtime in the prod environment.
|
||||
# To overcome this we load contents of those files at compilation time,
|
||||
# so that they become a part of the executable and can be served from memory.
|
||||
# We use Escript for distributing Livebook, so we don't have access to the static
|
||||
# files at runtime in the prod environment. To overcome this we load contents of
|
||||
# those files at compilation time, so that they become a part of the executable
|
||||
# and can be served from memory.
|
||||
defmodule AssetsMemoryProvider do
|
||||
use LivebookWeb.MemoryProvider,
|
||||
from: :livebook,
|
||||
from: Path.expand("../../static", __DIR__),
|
||||
gzip: true
|
||||
end
|
||||
|
||||
|
@ -35,8 +35,8 @@ defmodule LivebookWeb.Endpoint do
|
|||
|
||||
if code_reloading? do
|
||||
# In development we use assets from tmp/static_dev (rebuilt dynamically on every change).
|
||||
# Note that this directory doesn't contain predefined files (e.g. images),
|
||||
# so we also use `AssetsMemoryProvider` to serve those from priv/static.
|
||||
# Note that this directory doesn't contain predefined files (e.g. images), so we also
|
||||
# use `AssetsMemoryProvider` to serve those from static/.
|
||||
plug LivebookWeb.StaticPlug,
|
||||
at: "/",
|
||||
file_provider: AssetsFileSystemProvider,
|
||||
|
|
2
mix.exs
|
@ -118,7 +118,7 @@ defmodule Livebook.MixProject do
|
|||
links: %{
|
||||
"GitHub" => "https://github.com/livebook-dev/livebook"
|
||||
},
|
||||
files: ~w(lib priv config mix.exs mix.lock README.md LICENSE CHANGELOG.md)
|
||||
files: ~w(lib static config mix.exs mix.lock README.md LICENSE CHANGELOG.md)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |