Skip to content

Commit 2697dbf

Browse files
committed
Improve development setup
1 parent c74f004 commit 2697dbf

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ COPY demo/package.json demo/yarn.lock demo/.stylelintrc.json ./
5858

5959
COPY assets ../assets/
6060
COPY package.json ../
61-
COPY priv/static/js ../priv/static/js/
6261

6362
RUN yarn install --pure-lockfile
6463

demo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ erl_crash.dump
2222
demo-*.tar
2323
/priv/cert
2424
/priv/static/assets/
25+
/priv/static/js
2526
/priv/static/cache_manifest.json
2627
report.*.json
2728
openapi.json

demo/assets/js/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import * as Sentry from '@sentry/browser'
33
import topbar from 'topbar'
44
import { Socket } from 'phoenix'
55
import { LiveSocket } from 'phoenix_live_view'
6-
import { Hooks as BackpexHooks } from 'backpex'
6+
// in your app.js, just use 'backpex' like this:
7+
// import { Hooks as BackpexHooks } from 'backpex'
8+
import { Hooks as BackpexHooks } from '#backpex'
79

810
/**
911
* Sentry

demo/config/config.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ config :esbuild,
5656
~w(assets/js/app.js --bundle --target=es2017 --outdir=priv/static/assets --external:/fonts/* --external:/images/*),
5757
cd: Path.expand("..", __DIR__),
5858
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
59+
],
60+
backpex: [
61+
args:
62+
~w(../assets/js/backpex.js --bundle --format=esm --sourcemap --outfile=priv/static/js/backpex.esm.js),
63+
cd: Path.expand("..", __DIR__),
64+
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
5965
]
6066

6167
config :tailwind,

demo/config/dev.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ config :demo, DemoWeb.Endpoint,
1616
code_reloader: true,
1717
check_origin: false,
1818
watchers: [
19+
backpex: {Esbuild, :install_and_run, [:backpex, ~w(--sourcemap=inline --watch)]},
1920
esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
2021
tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
2122
],
@@ -26,7 +27,8 @@ config :demo, DemoWeb.Endpoint,
2627
~r"demo/lib/demo_web/helpers.ex$",
2728
~r"demo/lib/demo_web/(live|views)/.*(ex)$",
2829
~r"demo/lib/demo_web/templates/.*(eex)$",
29-
~r"lib/backpex/(fields|html)/.*(ex)$"
30+
~r"lib/backpex/(fields|html)/.*(ex)$",
31+
~r"priv/static/js/.*(js)$"
3032
]
3133
],
3234
force_ssl: [hsts: true],

demo/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"private": true,
3+
"imports": {
4+
"#backpex": "./priv/static/js/backpex.esm.js"
5+
},
36
"scripts": {
47
"test": "env $(cat .env.test | xargs) mix test",
58
"test:playwright": "env $(cat .env.test | xargs) mix test --include playwright:true",
@@ -30,7 +33,6 @@
3033
"topbar": "3.0.0"
3134
},
3235
"dependencies": {
33-
"backpex": "file:..",
3436
"daisyui": "^5.0.3"
3537
}
3638
}

0 commit comments

Comments
 (0)