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

367
Views
Nuxt plugin does not copy imported files to .nuxt

In a Nuxt project (version 2.14.9) I have a plugin file /plugins/ui-components.js that starts like this:

import UiList from '../components/UiList.vue'
import UiPageHeading from '../components/UiPageHeading.vue'
// more imports etc.

In nuxt.config.js I reference a file like this:

{
  // ...
  buildModules: [
    {
      handler: require('../lib/module.js'),
      options: {},
    },
  ],
}

Finally in ..lib/module.js I have

this.addPlugin({
    fileName: path.join(OUTPUT_DIR, 'plugins', 'ui-components.js'),
    src: path.resolve(__dirname, 'plugins/ui-components.js'),
    options: {
      registerDynamicComponentGlobally:
        options.registerDynamicComponentGlobally,
    },
  })

Now when I build or run the project ui-components.js gets copied to .nuxt, but not the .vue files that it imports. How can I fix this? My current workaround is to "manually" copy the files to .nuxt but of course I am looking for a better solution. Could it be that the plugin files need to be "stand-alone" meaning they are not allowed to import/require other dependencies?

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!