babel-plugin-wildcard icon indicating copy to clipboard operation
babel-plugin-wildcard copied to clipboard

wildcard and resolve.alias can't work at the same time

Open KumaCool opened this issue 5 years ago • 1 comments

wildcard and resolve.alias can't work at the same time my project is built with VueCli3 webpack set the resolve.alias '@' folder:

src/
├─ views/
│   ├─ index.vue
│   ├─ test.vue

code:

import { Index as temp } from '@/views/*';
console.log(temp);

error:Uncaught Error: Cannot find module '@/views/*'

KumaCool avatar Mar 03 '19 10:03 KumaCool

I don't know about webpack resolve.alias specifically but for this I use: https://www.npmjs.com/package/babel-plugin-root-import which is babel plugin that makes babel resolve the @ path. (There's also https://www.npmjs.com/package/babel-plugin-module-resolver which is popular but I don't use that one personally)

vihanb avatar May 15 '19 22:05 vihanb