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

166
Views
Including multiple JS files in the Loader for Webpack 5

I am working on an AFRAME web application, trying to include multiple components I am using that have already been created a distributed through the AFRAME community. Now I know how to import modules from other JS files but AFRAME isn't built to use require or import unless I use webpack since everything needs to load before the HMTL does. Currently in my webpack.dev.config file I have my loader here

module: {
        rules:[
            {
                test: /\.(png|jpg)$/,
                type: 'asset',
                parser: {
                    dataUrlCondition:{
                        maxSize: 3 * 1024,
                    },
                },
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                include: ['src', require.resolve('aframe-physics-system')],
                use:{
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/env'],
                        plugins: ['@babel/plugin-proposal-class-properties'],
                    },
                },
            },
        ],
    }

Which I am requiring one of the current components that I am using from the community. But I would like to include more because I want to be able to use the config loader to load all the components that way so I don't have to go an download each script and actually keep it inside my source project. I am more than likely overthinking this, but how/can the include property be formatted to allow multiple require.resolve() calls?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yup I was overthinking.

                test: /\.js$/,
                exclude: /node_modules/,
                include: ['src', require.resolve('aframe-physics-system'), require.resolve('another module')],
                use:{
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/env'],
                        plugins: ['@babel/plugin-proposal-class-properties'],
                    },
                },
            },
about 4 years ago · Juan Pablo Isaza Report
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!