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
Change the URL to
https://app.storyblok.com. Learn how to serve a local dev server over HTTPS on macOS and Windows. -
Change the plugin name
Open the file
src/Plugin.vueand change the plugin name in theinitWithmethod 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’ve 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 Save. Now, you should be able to see what you developed locally without having to runlocalhost. Make sure the name of your plugin is the same as inPlugin.vue, otherwise the import will fail.
Was this page helpful?
This site uses reCAPTCHA and Google's Privacy Policy (opens in a new window).Terms of Service (opens in a new window) apply.
Get in touch with the Storyblok community