title: Avoid relative paths when doing an import in node
body: <p>In my vue-cli project, I have the following file structure:</p>
  
  <ul>
  <li>src
  
  <ul>
  <li>components
  
  <ul>
  <li>Component1.vue</li>
  <li>Component2.vue</li>
  </ul></li>
  <li>router
  
  <ul>
  <li>routes
  
  <ul>
  <li>index.js</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>And I need to import my components in my <code>router/routes/index.js</code> in order to handle navigation:</p>
  
  <pre><code>import Component1 from '../../components/Component1.vue'
  import Component2 from '../../components/Component2.vue'
  
  const routes = [
      { path: '/route1', component: Component1 },
      { path: '/route2', component: Component2 }
  ]
  </code></pre>
  
  <p>I would like to avoid the full path navigation using <code>..</code>, and instead be able to set my <code>src</code> folder as a "root" path, in order to do the following:</p>
  
  <pre><code>import Component1 from 'src/components/Component1.vue'
  import Component2 from 'src/components/Component2.vue'
  </code></pre>
  
  <p>I've read the following article, but I only found solutions regarding <code>require</code> statements, not <code>import</code>s, and I'd like to keep my homogeneity.</p>
  
  <p><a href="https://gist.github.com/branneman/8048520" rel="nofollow noreferrer">https://gist.github.com/branneman/8048520</a></p>
  
  <p>What are the possible ways of doing this, either using node or an npm library?</p>
  
  <p>Thanks in advance.</p>