Build assets to tmp/static_dev in development

This commit is contained in:
Jonatan Kłosko 2021-05-19 23:50:18 +02:00
parent 7e4eccbf6d
commit 406c17dc43
6 changed files with 5 additions and 14 deletions

View file

@ -10,6 +10,5 @@ erl_crash.dump
livebook-*.tar
npm-debug.log
/assets/node_modules/
/priv/static_dev/
/tmp/
/livebook

8
.gitignore vendored
View file

@ -28,14 +28,6 @@ npm-debug.log
# The directory NPM downloads your dependencies sources to.
/assets/node_modules/
# During development we build assets from assets/
# and they end up in priv/static_dev/, from where they are served.
#
# For deployment we build the assets to priv/static/
# and commit to the reposity, because they have to be accessible
# when building Escript locally.
/priv/static_dev/
# The directory used by ExUnit :tmp_dir
/tmp/

View file

@ -17,7 +17,7 @@ module.exports = (env, options) => {
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, (devMode ? '../priv/static_dev/js' : '../priv/static/js')),
path: path.resolve(__dirname, (devMode ? '../tmp/static_dev/js' : '../priv/static/js')),
publicPath: '/js/'
},
devtool: devMode ? 'eval-cheap-module-source-map' : undefined,

View file

@ -51,7 +51,7 @@ config :livebook, LivebookWeb.Endpoint,
config :livebook, LivebookWeb.Endpoint,
live_reload: [
patterns: [
~r"priv/static_dev/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"tmp/static_dev/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"lib/livebook_web/(live|views)/.*(ex)$",
~r"lib/livebook_web/templates/.*(eex)$"
]

View file

@ -28,13 +28,13 @@ defmodule LivebookWeb.Endpoint do
defmodule AssetsFileSystemProvider do
use LivebookWeb.FileSystemProvider,
from: {:livebook, "priv/static_dev"}
from: {:livebook, "tmp/static_dev"}
end
# Serve static failes at "/"
if code_reloading? do
# In development we use assets from priv/static_dev (rebuilt dynamically on every change).
# 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.
plug LivebookWeb.StaticPlug,

View file

@ -85,7 +85,7 @@ defmodule Livebook.MixProject do
links: %{
"GitHub" => "https://github.com/elixir-nx/livebook"
},
files: ~w(lib priv/static config mix.exs README.md LICENSE CHANGELOG.md)
files: ~w(lib priv config mix.exs README.md LICENSE CHANGELOG.md)
]
end
end