Skip to main content
To preview, build, and export your emails, the Vuemail CLI compiles them with Vite and @vitejs/plugin-vue, loading every email through Vite’s server-side module loader. There’s nothing to configure: it works with the files you already have.

What’s supported

  • Single file components, including <script setup lang="ts">
  • TypeScript, in .vue files and in the modules they import
  • Path aliases from the paths of your tsconfig.json, like "@/*": ["./*"]
  • JSON imports, like import messages from '../messages/en.json'
  • Raw imports, with the ?raw suffix, like import theme from './theme.css?raw', which is how you can keep the CSS for the theme prop of Tailwind in a .css file. Not every bundler supports ?raw though: for emails your Nuxt server routes import too, keep that CSS in a string exported from a .ts file instead, as in the Nuxt guide
  • Dependencies, from node_modules or from other packages of your workspace
  • Static files: image URLs in templates, like <Img src="/static/logo.png" />, stay URLs instead of becoming module imports, so the preview can serve them from emails/static
Every render uses the latest code of the email and of the files it imports, so changes to any of them show up in email dev right away.
emails/welcome.vue

What’s not supported

  • Your Vite configuration: the CLI doesn’t load vite.config.ts, so plugins you add there don’t apply to your emails. Pass the plugins your emails need with --vite-plugins instead.
  • .env files: they aren’t loaded either. process.env has the environment variables of the process running the CLI, set by your shell or your tooling.

Compiling emails in your own code

Node.js can’t import .vue files on its own, so the code that renders your emails with render has to be compiled with a Vue plugin too. Keep the URLs of images as they are, like the CLI does, by turning off transformAssetUrls.
Add the @vuemaildev/nuxt module, and import emails from your server routes. See Nuxt.
nuxt.config.ts