webpack icon indicating copy to clipboard operation
webpack copied to clipboard

import component works, require(component) does not

Open iannazzi opened this issue 7 years ago • 0 comments

I used vue-webpack to start a new project for which I am importing an old project into. In the past I used require to load a component, which was nice as I could dry up some code for common names, routes, files.

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import dashboard from '@/pages/dashboard/dashboard'


Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
     {
        path: '/dashboard',
        name: 'dashboard',
        //component: dashboard //works fine

        //component: require('@/pages/dashboard/dashboard')  
        

        component: require('../pages/dashboard/dashboard')  


        //neither require works.... error: 
        // [Vue warn]: Failed to mount component: template or render function not defined.
        // found in
        // ---> <Anonymous>
        //        <App> at src/App.vue
        //          <Root>
        

    },
  ]
})

Any ideas? I did need to modify the webpack.bas.config.js a bit. Let me know what else you need or where to look, in the meantime, i will trod forward with imports.

Thanks!

iannazzi avatar Aug 31 '18 13:08 iannazzi