2

I want to write local docusaurus plugins using typescript. (it works fine using js)

Is this possible? Like the docs here suggest to put them under ./src/plugins/name-of-plugin.

Reading the docs there are examples with ts, but if I just try and replace is with ts i get various errors. (eg "Cannot find module").

I'm using typescript for pages as well.

Gustav
  • 3,408
  • 4
  • 24
  • 41

1 Answers1

0

Adding the file extension worked for me. For example:

plugins: ['./src/plugins/my-plugin.ts'],

my-plugin.ts

module.exports = async function myPlugin(context, options) {
  return {
    name: "my-plugin",
    async loadContent() {
      console.log("Hello World plugin wow!");
    },
    async contentLoaded({ content, actions }) {
      console.log(content);
    },
  };
};

removing the extension shows the same error :)

Anas Laham
  • 21
  • 2