Docs: Adding details about how to enable dynamic imports in plugins (#41648)

* added dynamic import to the readme.

* Update packages/grafana-toolkit/README.md

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* Update README.md

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
Marcus Andersson 2021-11-15 10:20:55 +01:00 committed by GitHub
parent 5c40865547
commit 95e0eea86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -300,6 +300,24 @@ If your comments include ES2016 code, then SystemJS v0.20.19, which Grafana uses
To fix this error, remove the ES2016 code from your comments.
### I would like to dynamically import modules in my plugin
Create a webpack.config.js with this content (in the root of _your_ plugin)
```ts
// webpack.config.js
const pluginJson = require('./src/plugin.json');
module.exports.getWebpackConfig = (config, options) => ({
...config,
output: {
...config.output,
publicPath: `public/plugins/${pluginJson.id}/`,
},
});
```
The plugin id is the id written in the plugin.json file.
## Contribute to grafana-toolkit
You can contribute to grafana-toolkit by helping develop it or by debugging it.