The webpack packaging entry specifies all js in a folder as entry files

webpack.config.js

// webpack.config.js 
const path =  require ( 'path' ) 
const glob =  require ( 'glob' )

module . exports =  { 
  // Specify the js file in the packs folder as the entry file 
  // glob.sync gets the path of all js files in the folder 
  entry : glob . sync ( "./packs/*.js" ) . reduce ( ( entries , p )  =>  { 
    const name = path . basename ( p ,  '.js' )  // get the filename of the path aaa/bbb.js => bbb 
    return  {  ... entries ,  [ name ] : p }
  } ,  { } ) , 
  ... 
 }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

Tags: The webpack packaging entry specifies all js in a folder as entry files

webpack webpack entry

Related: The webpack packaging entry specifies all js in a folder as entry files