4

I'm creating a non-SPA website and wanted to use webpack, but I can't achieve situation when I have multiple input files and multiple output files. My input files has structure:

-/front -app.js -/js -main.js -login.js

and I want output to be:

-/web -/bundles -main.js -login.js

here's beginning of my webpack.config.js:

module.exports = {
    context: path.resolve('src/front'), // main webpack folder
    entry: ["./app.js"],
    output: {
        filename: "./web/bundles/[name].js"
    },

Is it even achievable?

Now, only all required files in app.js are bundles under the name main.js in /web/bundles folder. How to change it?

1 Answer 1

10

Use multiple entry points like this:

entry: {
  app: './app',
  main: './js/main.js',
  login: './js/login.js',
},
output: {
  path: path.join(__dirname, './public'),
  filename: '[name].js'
},
Sign up to request clarification or add additional context in comments.

2 Comments

ok, but when I'll add more files, I will have to update config all the time. Isn't there is something like gulp's expressions like '*/.js' ?
This question is solved seems you have success. And whilecard is another question you can read about it there or ask new question. I hope you will have success.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.