Skip to content

Commit

Permalink
Update build.mjs to work with esbuild > 0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
cruessler committed Oct 29, 2023
1 parent d07aaa5 commit 673ba80
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
39 changes: 13 additions & 26 deletions assets/build.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// 2023-04-07
//
// This file does not work with esbuild > 0.16 as esbuild’s API has changed in
// 0.17.
//
// esbuild-sass-plugin is pinned to version < 2.6 because versions > 2.5 require
// esbuild 0.17.
//
// https://github.com/evanw/esbuild/blob/main/CHANGELOG.md#0170

import esbuild from 'esbuild';
import ElmPlugin from 'esbuild-plugin-elm';
import { sassPlugin } from 'esbuild-sass-plugin';
Expand Down Expand Up @@ -35,29 +25,26 @@ let opts = {
plugins,
};

if (watch) {
opts = {
...opts,
watch,
sourcemap: 'inline',
};
}

if (deploy) {
opts = {
...opts,
minify: true,
};
}

const promise = esbuild.build(opts);

if (watch) {
promise.then((_result) => {
process.stdin.on('close', () => {
process.exit(0);
opts = {
...opts,
sourcemap: 'inline',
};
esbuild
.context(opts)
.then((ctx) => {
ctx.watch();
})
.catch((_error) => {
process.exit(1);
});

process.stdin.resume();
});
} else {
esbuild.build(opts);
}
2 changes: 1 addition & 1 deletion lib/ex_rss_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule ExRssWeb.Endpoint do
at: "/",
from: :ex_rss,
gzip: false,
only: ~w(css fonts images js favicon.ico robots.txt)
only: ~w(assets fonts images favicon.ico robots.txt)

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
Expand Down
4 changes: 2 additions & 2 deletions lib/ex_rss_web/templates/layout/app.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<meta name="author" content="">

<title>Hello ExRss!</title>
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>">
<link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/assets/app.css") %>">
<script phx-track-static src="<%= Routes.static_path(@conn, "/assets/app.js") %>"></script>
</head>

<body>
Expand All @@ -19,6 +20,5 @@
<%= @inner_content %>

</div> <!-- /container -->
<script src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
</body>
</html>

0 comments on commit 673ba80

Please sign in to comment.