0

Is there a way to build a webpack application with kind of this?

--src
|  |--home
|  |   |--script.js
|  |
|  |--smt
|      |--script.js
--dist
|  |--home
|  |   |--script.js
|  |
|  |--smt
|      |--script.js

I found a way to perform set entry point for a directory or multiple files. But the output is always like:

|--dist
|   |--script1.js
|   |--script2.js
|   |--etc.js

So, can I compile all files with directories relationships?

Yoskutik
  • 1,859
  • 2
  • 17
  • 43
  • Maybe already answered here https://stackoverflow.com/questions/35903246/how-to-create-multiple-output-paths-in-webpack-config – Jake Jul 13 '19 at 22:57

1 Answers1

0

Thanks everyone. Here I found a way:

webpack.config.js:

let entry = {};
glob.sync('./dev/**/*.*').forEach(p => {
    entry[p.replace('./dev/', '')] = p;
});
/*...*/
module.exports = {
  entry,
  output: {
    path: path.resolve(__dirname, 'prod'),
    filename: '[name]',
  }
//...
}
Yoskutik
  • 1,859
  • 2
  • 17
  • 43