The webpack docks have:

module.exports = { entry: { app: './src/app.js', search: './src/search.js' }, output: { filename: '[name].js', path: __dirname + '/dist' } }; 

It turns out that in the entry you can specify the path to any file in src.

Question: how is it right now to specify in the webpack 4 output paths to different folders, for example, save app.js to / dist / app /, and search.js to / dist / search /?

    1 answer 1

    Unfortunately - no way. You can only have one output path. , but you can use several configs and export an array with these configs:

     // webpack.config.js const { join } = require('path'); const appConfig = { entry: './src/app.js', output: { filename: '[name].js', path: join(__dirname, 'dist/app') } }; const searchConfig = { entry: './src/search.js', output: { filename: '[name].js', path: join(__dirname, 'dist/search') } }; const common = { context: __dirname, module: { rules: [...] } }; module.exports = [{ ...common, ...appConfig }, { ...common, ...searchConfig }];