Add plugins port settings

This commit is contained in:
Pierre Burgy 2017-09-09 15:49:59 +02:00
parent 102a9a00d1
commit 919a7b33ce
3 changed files with 21 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import { ConnectedRouter } from 'react-router-redux';
import createHistory from 'history/createBrowserHistory';
import _ from 'lodash';
import 'sanitize.css/sanitize.css';
import 'whatwg-fetch';
import LanguageProvider from 'containers/LanguageProvider';
@ -21,6 +22,7 @@ import App from 'containers/App';
import { showNotification } from 'containers/NotificationProvider/actions';
import { pluginLoaded, updatePlugin } from 'containers/App/actions';
import { plugins } from '../../config/admin.json';
import configureStore from './store';
import { translationMessages, languages } from './i18n';
@ -123,3 +125,18 @@ window.Strapi = {
router: history,
languages,
};
// Ping each plugins port defined in configuration
plugins.ports.forEach(pluginPort => {
// Define plugin url
const pluginUrl = `http://localhost:${pluginPort}/main.js`;
// Check that the server in running
fetch(pluginUrl)
.then(() => {
// Inject `script` tag in DOM
const script = window.document.createElement('script');
script.src = pluginUrl;
window.document.body.appendChild(script);
});
});

View File

@ -13,5 +13,4 @@
<div id="app"></div>
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically includes all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this HTML file. Don't add any assets here! (Check out webpackconfig.js if you want to know more) -->
</body>
<script type="text/javascript" src="http://localhost:3000/main.js"></script>
</html>

View File

@ -1,3 +1,6 @@
{
"languages": ["en", "fr"]
"languages": ["en", "fr"],
"plugins": {
"ports": [3000]
}
}