code-farmer-i / vite-plugin-prismjs

10 stars 0 forks source link

Getting Error when using with react-ts #1

Open yaldram opened 2 years ago

yaldram commented 2 years ago

// https://vitejs.dev/config/ export default defineConfig({ plugins: [ prismjs({ languages: ["javascript"], plugins: [], theme: "twilight", css: false, }), react({ babel: { plugins: [ [ "babel-plugin-styled-components", { displayName: true, fileName: false, }, ], [ "prismjs", { languages: ["javascript"], plugins: [], theme: "twilight", css: false, }, ], ], }, }), ], });



I have the following dependencies - `babel-plugin-prismjs, vite-plugin-prismjs`.

My error - 
<img width="863" alt="image" src="https://user-images.githubusercontent.com/13429535/161008740-6af5d3c9-ca1d-4303-80b1-592a06be1145.png">
code-farmer-i commented 2 years ago

Need to install dependency prismjs

yaldram commented 2 years ago

@code-farmer-i I do have it prismjs.

yaldram commented 2 years ago

I followed this - https://cdmana.com/2022/03/202203242042274722.html

yaldram commented 2 years ago

I got it working without this plugin also -

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react({
      babel: {
        plugins: [
          [
            "babel-plugin-styled-components",
            {
              displayName: true,
              fileName: false,
            },
          ],
          [
            "prismjs",
            {
              languages: ["javascript"],
              plugins: [],
              theme: "twilight",
              css: false,
            },
          ],
        ],
      },
    }),
  ],
});
yaldram commented 2 years ago

This config worked -

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import prismjs from "vite-plugin-prismjs";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react({
      babel: {
        plugins: [
          [
            "babel-plugin-styled-components",
            {
              displayName: true,
              fileName: false,
            },
          ],
          [
            "prismjs",
            {
              languages: ["javascript"],
              plugins: [],
              theme: "twilight",
              css: false,
            },
          ],
        ],
      },
    }),
    prismjs({
      languages: ["javascript"],
      plugins: [],
      theme: "twilight",
      css: false,
    }),
  ],
});
yaldram commented 2 years ago

@code-farmer-i Sir may I know the use of this plugin can I skip it, will it cause any problem.

code-farmer-i commented 2 years ago

I have only tried to use this plugin in a vue project