/** * app.js * * This is the entry file for the application, * only setup and plugin code. */ import './public-path.js'; // eslint-disabled-line import React from 'react'; import { Provider } from 'react-redux'; import App from 'containers/App'; // eslint-disable-line import configureStore from './store'; import { translationMessages } from './i18n'; const tryRequire = (bootstrap = false) => { try { const config = bootstrap ? require('../../../../admin/src/bootstrap.js').default : require('../../../../admin/src/requirements.js').default; return config; } catch(err) { return null; } }; const bootstrap = tryRequire(true); const pluginRequirements = tryRequire(); let injectedComponents; try { injectedComponents = require('injectedComponents').default; } catch(err) { injectedComponents = []; } // Plugin identifier based on the package.json `name` value const pluginPkg = require('../../../../package.json'); const pluginId = pluginPkg.name.replace( /^strapi-plugin-/i, '' ); const pluginName = pluginPkg.strapi.name; const pluginDescription = pluginPkg.strapi.description || pluginPkg.description; const apiUrl = `${strapi.backendURL}/${pluginId}`; const router = strapi.router; // Create redux store with Strapi admin history const store = configureStore({}, strapi.router); // Define the plugin root component function Comp(props) { return ( ); } // Hot reloadable translation json files if (module.hot) { // modules.hot.accept does not accept dynamic dependencies, // have to be constants at compile-time module.hot.accept('./i18n', () => { if (strapi) { System.import('./i18n').then(result => { const translationMessagesUpdated = result.translationMessages; strapi .refresh(pluginId) .translationMessages(translationMessagesUpdated); }); } }); } // Register the plugin. strapi.registerPlugin({ name: pluginPkg.strapi.name, icon: pluginPkg.strapi.icon, description: pluginDescription, id: pluginId, leftMenuLinks: [], mainComponent: Comp, translationMessages, bootstrap, pluginRequirements, preventComponentRendering: false, blockerComponent: null, injectedComponents, blockerComponentProps: {}, }); // Export store export { store, apiUrl, pluginId, pluginName, pluginDescription, router };