最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - webpack multiple entries in a directory - Stack Overflow

programmeradmin0浏览0评论
context: path.join(__dirname, 'resources/assets/bundle/js'),
  entry: [
    'webpack/hot/dev-server',
    'webpack-hot-middleware/client',
    './*.js'
  ]

Is above code even valid? instead of specifying every single file like

context: path.join(__dirname, 'resources/assets/bundle/entries'),
  entry: [
    'webpack/hot/dev-server',
    'webpack-hot-middleware/client',
    './abc.js',
    './def.js'
  ]

how can I include entire folder?

context: path.join(__dirname, 'resources/assets/bundle/js'),
  entry: [
    'webpack/hot/dev-server',
    'webpack-hot-middleware/client',
    './*.js'
  ]

Is above code even valid? instead of specifying every single file like

context: path.join(__dirname, 'resources/assets/bundle/entries'),
  entry: [
    'webpack/hot/dev-server',
    'webpack-hot-middleware/client',
    './abc.js',
    './def.js'
  ]

how can I include entire folder?

Share Improve this question asked Feb 15, 2017 at 3:10 Jessica Robertson Jessica Robertson 4371 gold badge7 silver badges17 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

Why do you use the entire folder?

if you want entire folder , you can use glob npm module

As explained : https://github./webpack/webpack/issues/370

var glob = require("glob");
// ...
entry: glob.sync("./src/scripts/*.js")

but webpack is not remended entire folder, the entry value should resolve to a specific file, or a list of specific files.

You can easily do this by your own, as the webpack.config.js is just a node.js module and allows to execute any code. Wildcards in entry points

Webpack uses entry point to resolve the reference to generate the bundle. you can define multiple entry point based on the number of bundle needed. you should not be adding entire folder as entry point, it means you want bundle of each file inside the folder, which webpack does not remend.

https://webpack.github.io/docs/multiple-entry-points.html

发布评论

评论列表(0)

  1. 暂无评论