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
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • 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

    Discontinued 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.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • 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