Local development
If you want to create more complex plugins you have also the option to develop a plugin with a local dev environment using your favorite editor. This lets you load other plugins and organize your code in multiple files.
-
Clone the repository and run the dev server
Terminal window git clone https://github.com/storyblok/storyblok-fieldtypecd storyblok-fieldtypenpm installnpm run devThis will spin up a server on
http://localhost:8080. -
Change the URL of the dev server
Please change your URL to
https://app.storyblok.comfromhttp://app.storyblok.com. In this FAQ, you can read how to set up a dev server with an HTTPS proxy on MacOS. -
Change the plugin name
Open the file
src/Plugin.vueand change the plugin name in the initWith method to the one you created in Storyblok.initWith() {return {// needs to be equal to your storyblok plugin nameplugin: 'my-plugin-name',title: '',description: ''}} -
Enable local dev mode
Now you can click the checkbox Enable local dev mode in the Plugin Editor to load your local environment into the field plugin preview and start developing your plugin.
-
Deployment
When you finished developing your plugin you need to run
npm run buildand copy the content of the filedist/export.jsinto the editor text field of the Storyblok app and click the Save button. Now, you should be able to see what you developed locally without having the localhost running. Make sure the name of your plugin is the same as inPlugin.vue, otherwise the import will fail.
Get in touch with the Storyblok community