Keep static files outside priv (#602)

* Keep static files outside priv

* Override generated assets on the CI
This commit is contained in:
Jonatan Kłosko 2021-10-18 22:32:09 +02:00 committed by GitHub
parent 3a8c11cb10
commit a41dda9c7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
139 changed files with 14 additions and 12 deletions

View file

@ -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

View file

@ -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")

View file

@ -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)

View file

@ -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/",
},

View file

@ -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,

View file

@ -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

View file

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View file

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Some files were not shown because too many files have changed in this diff Show more