-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Currently if we generate the projects using the CLI for example
ara new:nova novas/global -t vue
There are two files we need to modify in case we need to change the name of the nova service from Example (if we are enabling SSR as well)
- client.js
- index.js
There is a change that the developer may miss out modifying the name in all places.
Possible Solution
Add a common place where the name is specified for example
constants.js
const NOVA_NAME = 'VueNovaMFE';
export default NOVA_NAME;
Now in each of the files index.js and client.js
include it
import NOVA_NAME from './constants';
The index.js could look like this
hypernova({
devMode: process.env.NODE_ENV !== 'production',
getComponent(name) {
if (name === NOVA_NAME) {
return renderVue(name, Vue.extend(MonthlySalesChart));
}
},
port: process.env.PORT || 3000,
createApplication() {
const app = express();
app.use('/public', express.static(path.join(process.cwd(), 'dist')));
return app;
},
});
Similarly the client.js could look like this
import NOVA_NAME from './constants';
const render = (name, { node, data }) => {
if (name === NOVA_NAME) {
return mountComponent(Vue.extend(MonthlySalesChart), node, data);
}
};
document.addEventListener('NovaMount', ({ detail }) => {
const { name, id } = detail;
const payload = loadById(name, id);
if (payload) {
render(name, payload);
}
});
load(NOVA_NAME).forEach(render.bind(null, NOVA_NAME));
Metadata
Metadata
Assignees
Labels
No labels