Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
How to export all vue components from folder with index.js?

I want to export all vue components from folder. But I face error with this code

@components/index.js < code 1

import camelCase from "lodash/camelCase";
const requireModule = require.context(".", false, /\.vue$/);
const modules = {};

requireModule.keys().forEach(fileName => {
  const moduleName = camelCase(fileName.replace(/(\.\/|\.vue)/g, "")); //

  modules[moduleName] = requireModule(fileName).default;
});
export default modules;

if I export simply, it's no problem

@components/index.js < code 2

export { default as ButtonStyled } from './ButtonStyled.vue'
export { default as InputStyled } from './InputStyled.vue'

and I want to import like this:

import { InputStyled } from '@components'

Here code 2 is ok, but I need code 1. I tried with this packeage yungsilva/named-exports but not ok.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!