Skip to content

Commit

Permalink
Merge pull request #602 from opensafely-core/vite-deps
Browse files Browse the repository at this point in the history
Update Vite pipeline with HTMX and fonts
  • Loading branch information
tomodwyer authored Sep 6, 2024
2 parents cd1bcae + aa6f016 commit 42c94eb
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 3 deletions.
1 change: 0 additions & 1 deletion airlock/static/htmx-1.9.10.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion airlock/templates/file_browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{% endblock full_width_content %}

{% block extra_js %}
<script type="text/javascript" src="{% static 'htmx-1.9.10.min.js' %}"></script>
{% vite_asset "assets/src/scripts/htmx.js" %}
{% django_htmx_script %}
<script src="{% static 'assets/file_browser/index.js' %}"></script>
{% vite_asset "assets/src/scripts/resizer.js" %}
Expand Down
1 change: 1 addition & 0 deletions assets/src/scripts/htmx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "htmx.org";
1 change: 1 addition & 0 deletions assets/src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import "vite/modulepreload-polyfill";
import "@fontsource-variable/public-sans";
import "../styles/main.css";
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
"postcss": "^8.4.40",
"tailwindcss": "^3.4.7",
"vite": "^5.3.5"
},
"dependencies": {
"@fontsource-variable/public-sans": "^5.0.19",
"htmx.org": "^1.9.12"
}
}
20 changes: 19 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
theme: {
extend: {
fontFamily: {
sans: ["Public Sans", ...fontFamily.sans],
sans: ["Public Sans Variable", ...fontFamily.sans],
},
colors: {
oxford: {
Expand Down Expand Up @@ -187,5 +187,23 @@ export default {
plugins: [
tailwindTypography,
tailwindForms,
({ addBase, theme }) => {
function extractColorVars(colorObj, colorGroup = "") {
return Object.keys(colorObj).reduce((vars, colorKey) => {
const value = colorObj[colorKey];

const newVars =
typeof value === "string"
? { [`--color${colorGroup}-${colorKey}`]: value }
: extractColorVars(value, `-${colorKey}`);

return { ...vars, ...newVars };
}, {});
}

addBase({
":root": extractColorVars(theme("colors")),
});
},
],
};
4 changes: 4 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ export default defineConfig({
outDir: "./assets/out",
rollupOptions: {
input: {
htmx: "assets/src/scripts/htmx.js",
main: "assets/src/scripts/main.js",
resizer: "assets/src/scripts/resizer.js",
},
},
},
server: {
origin: "http://localhost:5173",
},
});

0 comments on commit 42c94eb

Please sign in to comment.