1

I would like to be like to be able to get a relative import:

e.g.

import Router from '@/router/router.js'
import IndexController from '@/controller/index.js'

Is there a easy way to achieve this? I have never set it up myself but I was able to use it with frontendframe works such as react or vue when setting them up through their cli. I'm pretty sure they do it with webpack, but is there a way to achieve this flexibility without adding any additional tooling such as webpack?

Dominik
  • 397
  • 1
  • 3
  • 16
  • 1
    Have you tried combinations of `/router/router.js`, `./router/router.js`, `../router/router.js`, `../../router/router.js` ? I don't know your folder structure, so no idea which one is correct, but you can use single and double dots to refer to current dir, parent dir etc. Full possible path syntax can be found in the docs. – Shilly Apr 17 '19 at 15:20
  • Remove the `@` and it will prob work. – Isaac Vidrine Apr 17 '19 at 15:24
  • Just replace `@` with `src`. See https://stackoverflow.com/q/42749973/215552 – Heretic Monkey Apr 17 '19 at 15:24
  • @HereticMonkey thats assuming the `src` folder exists in their project – Isaac Vidrine Apr 17 '19 at 15:25
  • @IsaacVidrine Sure, that's why it's a comment, and I linked to a post where the OP can read about how it works. – Heretic Monkey Apr 17 '19 at 15:27
  • 1
    I was wondering if it was possible without webpack, but I assume not :) – Dominik Apr 17 '19 at 16:04

0 Answers0