How do i get PrismJS working with phoenix?

This page summarizes the projects mentioned and recommended in the original post on /r/elixir

Our great sponsors
  • Appwrite - The open-source backend cloud platform
  • Revelo Payroll - Free Global Payroll designed for tech teams
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • Sonar - Write Clean JavaScript Code. Always.
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • Highlight.js

    JavaScript syntax highlighter with language auto-detection and zero dependencies.

    If you just want to get up and running, try the example from this repo:

  • esbuild-plugin-babel

    Babel plugin for esbuild.

    As mentioned the frameworks have gone through some changes since then. Babel is hardly ever used these days, esbuild doesn't pick up the babel config automatically. If you're using the default esbuild config generated with a modern phx_new version, look into changing it to a custom build script in https://hexdocs.pm/phoenix/asset_management.html#esbuild-plugins and then integrate something like this plugin https://github.com/nativew/esbuild-plugin-babel to be able to run https://github.com/mAAdhaTTah/babel-plugin-prismjs. There is a comment at the bottom of the tutorial of someone getting it to work with live view by listening for a phx page loading event, but the more idiomatic way these days would be to use a hook.

  • Appwrite

    Appwrite - The open-source backend cloud platform. The open-source backend cloud platform for developing Web, Mobile, and Flutter applications. You can set up your backend faster with real-time APIs for authentication, databases, file storage, cloud functions, and much more!

  • babel-plugin-prismjs

    A babel plugin to use PrismJS with standard bundlers.

    As mentioned the frameworks have gone through some changes since then. Babel is hardly ever used these days, esbuild doesn't pick up the babel config automatically. If you're using the default esbuild config generated with a modern phx_new version, look into changing it to a custom build script in https://hexdocs.pm/phoenix/asset_management.html#esbuild-plugins and then integrate something like this plugin https://github.com/nativew/esbuild-plugin-babel to be able to run https://github.com/mAAdhaTTah/babel-plugin-prismjs. There is a comment at the bottom of the tutorial of someone getting it to work with live view by listening for a phx page loading event, but the more idiomatic way these days would be to use a hook.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts