To use it, begin by modifying the
./theme/js/script.min.js with a target environment of
esnext is esbuild’s default, but it is also set explicitly in your
package.json file, so you can easily update the target environment there if necessary.
And for a function, something like this:
Example: Installing and importing Alpine.js
Almost all of my website builds begin with WordPress and Tailwind. Then, as soon as it’s time to add interactivity, I install Alpine.js. (Via its website, Alpine describes itself as “jQuery for the modern web,” which both feels accurate and deeply undersells short the joys of using it. You should try it!)
This process is almost identical for other frameworks and libraries you may want to install, so the steps below are fairly representative. Always review the installation documentation for the library you’re hoping to install, and look for instructions explaining how to install via npm and import into a bundle.
For Alpine, the first step is to install it via npm:
npm install alpinejsCode language: plaintext (plaintext)
Then add the following to your
And that’s it! If you’re already running
npm run watch, Alpine will be available in your theme the moment you hit save (give or take a few milliseconds). If not, it will be added the next time you run any of your theme’s build commands.
Get started quickly, and deploy to production sooner than you expect
Generate your custom theme, install it in WordPress and run your first Tailwind builds
Watch for changes, build for production and learn more about how _tw, WordPress and Tailwind work together
Share your new WordPress theme with the world
Find solutions to potential issues and answers to frequently asked questions
- Using Tailwind Typography
Customize front-end and back-end typographic styles
- Linting and Code Formatting
Catch bugs and stop thinking about formatting