-
I can't get custom Alpine directive to work. I'm using rollup, and my issue is probably related to:
But I have no idea how to go about it.
import nodeResolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
export default {
input: "static/main.js",
output: {
file: "static/bundle.min.js",
format: "es",
plugins: [terser()],
},
plugins: [nodeResolve()],
onwarn: (entry, next) => {
if (
entry.loc?.file &&
/htmx\.esm\.js$/.test(entry.loc.file) &&
/Use of eval in/.test(entry.message)
)
return;
return next(entry);
},
};
import Alpine from "alpinejs";
import htmx from "htmx.org";
Alpine.directive("uppercase", (el) => {
el.textContent.toUpperCase();
});
window.Alpine = Alpine;
window.Alpine.start();
htmx.onLoad(() => {
console.log("htmx loaded");
});
<html>
<meta>
<script defer src="{% static 'bundle.min.js' %}"></script>
</meta>
<body>
<div x-data>
<span x-uppercase>Hello World!</span>
</div>
</body>
</html> If I use the |
Beta Was this translation helpful? Give feedback.
Answered by
ekwoka
Nov 1, 2024
Replies: 1 comment 5 replies
-
the above code works fine. What makes you think it's not working? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your code is
But the correct code is