In the output settings you can specify only 1 output place. And besides the dist folder, I need to copy to another place on the disk.

const path = require('path') const webpack = require('webpack') module.exports = { context: path.resolve(__dirname , 'src'), // ΠΊΠΎΡ€Π΅Π½ΡŒ контСкст // Π’ΠΎΡ‡ΠΊΠΈ Π²Ρ…ΠΎΠ΄Π° entry:{ home: './Home', //profile: './Profile', //shop: './Shop', }, output: { filename: 'bundle.js', path: path.resolve(__dirname , 'dist') }, plugins:[ new webpack.optimize.UglifyJsPlugin() ], watch: false, // слСТСниС Π·Π° обновлСниями devtool: 'source-map' // eval source-map } 

Can webpack do this?

    1 answer 1

    It does not know how, but you can use its capabilities, add your own plugin, whose callback will work after a certain life cycle, namely, after the webpack generates everything in the output directory:

     // webpack.config.js const { copyFileSync } = require('fs'); module.exports = { .... plugins: [ { apply: (compiler) => { compiler.hooks.afterEmit.tap('AfterEmitPlugin', () => { copyFileSync('./dist/bundle.js', './новая-дирСктория/bundle.js') }); } } ] }; 
    • I understand that this approach is wrong. webpack is intended only for building a project, and already copying or something else needs to be done with the help of other tools (for example, gulp). - manking
    • if such an approach were wrong, then there would be no mention of plug-ins, and the galp is just a task manager - overthesanity
    • Then it would be part of the engine as in gulp and it was done simply. I understand that this functionality is not specifically included in the webpack. - manking
    • there is nothing supernatural in the galp, the galp source code is 50+ lines of code, such functionality is not implied in any bundler, any bundler can have several input parameters and one output (that is, one output), but there are many tricks and workarounds - overthesanity
    • And how to find out the file name? './dist/build/static/js/[nameERSBANK_JS' I use create-react-app and there output is the following output: {path: paths.appBuild, filename: ' static / js / [name]. [chunkhash: 8] .js', chunkFilename: 'static / js / [name]. [chunkhash: 8] .chunk.js',}, - manking