Closed
Description
What problem does this feature solve?
For vue plugins, It's useful to have a code injection points (e.g import
, instance options) to main.js
.
e.g. vue-cli-plugin-apollo
replace main.js
https://github.com/Akryum/vue-cli-plugin-apollo/blob/master/generator/index.js#L81-L90
What does the proposed API look like?
I think that Geneartor API might need to injectToEntryPoint
the below:
module.exports = (api, options, rootOptions) => {
api.injectToEntryPoint({
import: 'i18n',
from: './i18n',
option: 'i18n'
})
}
In main.js
template, I think it can render like the below:
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/generator/template/src/main.js
import Vue from 'vue'
import App from './App.vue'
<%_ if (options.router) { _%>
import router from './router'
<%_ } _%>
<%_ if (options.vuex) { _%>
import store from './store'
<%_ } _%>
<%_ for(const plugin of options.plugins) { _%>
import <%= plugin.import %> from '<%= plugin.from %>'
<%_ } _%>
Vue.config.productionTip = false
new Vue({
<%_ if (options.router) { _%>
router,
<%_ } _%>
<%_ if (options.vuex) { _%>
store,
<%_ } _%>
<%_ for(const plugin of options.plugins) { _%>
<%= plugin.option %>,
<%_ } _%>
render: h => h(App)
}).$mount('#app')