-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pages in Modules #148
Comments
hey, // module.js
const { resolve } = require('path')
const newRoute = {
name: 'admin',
path: '/admin',
chunkName: 'admin',
component: resolve(__dirname, './path/to/components/admin.vue'),
}
module.exports = function module(moduleOptions) {
// do some stuf with options and default options.
// inject the new route
this.extendRoutes(routes => {
routes.unshift(newRoute)
})
// add plugin to provide dump components to make it available publicly through
// the whole app.
this.addPlugin({
src: resolve(__dirname, './path/to/module.components.plugin.js'),
fileName: 'module.components.js',
options, // if you need to inject some options.
})
} and in the plugin // module.components.plugin.js
import Vue from 'vue'
import myComponents from '~/modules/myModule/mycomponents.js'
// also you can provide a different path dynamically through the options of the module like:
// import SomeComponents from '<%= options.modulePath %>/someComponents.js
Vue.use(myComponents) // if you don't need to pass options
// or
// Vue.use(myComponents, <%= options %>) to pass the options of the module to
// the components.
export default function moduleComponentsPlugin(ctx) {
} and as any Vue plugin can provide components and directives like: // mycomponents.js
import SomeComponent from './path/to/moduleComponent.vue'
import SomeDirective from './path/to/moduleDirective.js'
export default {
install(Vue, options) {
Vue.component('SomeComponent', SomeComponent)
Vue.directive('some-directive', SomeDirective)
// ... add some logic or extend the vue prototype to add more public methods
}
} i hope it helps |
@rwatts3 was your question answered? Can we close this question? |
being able to use the same pages structure within a module would be nice |
I'm trying to create pages inside a module as npm package. |
Greetings,
Is there documentation on how to include pages folders via a modules ?
Essentially I would like to supply the module consumer with a /admin route already configured and ready to go.
Also I would like to provide a set of components for the end user as well.
The text was updated successfully, but these errors were encountered: