简体   繁体   中英

browserify / webpackify all the files in a directory

Is it possible to browserify / webpackify all the files in a directory;

from

src
|____a.js
|____b.js
.
.    

to

dist
|____a.js // browser compatible code
|____b.js // browser compatible code
.
.

as individual standalone files; not bundled into one , form cli/binary , just from npm scripts via babel w/o grunt/gulp etc.

These files are top level files, which are importing modular ones and will be consumed independently

You could set an entry for each like this:

{
  entry: [
    foo: '<path to foo>',
    bar: '<path to bar>'
  ],
  output: {
    filename: '[name].js'
  }
}

This will output a separate bundle for each entry.

An alternative way to solve this would be to return an array of configurations (webpack can pick that up). In this case each configuration would have a single entry. The advantage of doing this is that you could set up a little script to evaluate the separate configurations in parallel against webpack's Node API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM