admin管理员组文章数量:1026989
Im new to webpack and as i understand it, it will create a graph starting on the entry(ies) point and based on the require mands specified in each script thereafter.
Question 1:
I was wondering if there's a way for webpack to bundle up a bunch of specified files ( say all the files in a folder and all its subfolders ) somehow.
Question 2
Im not sure why it needs to create a graph to begin with. Wouldnt it be enough to keep a record of each library needed and only include it once at the final bundle.js script? Why a graph?
Thanks a lot
Im new to webpack and as i understand it, it will create a graph starting on the entry(ies) point and based on the require mands specified in each script thereafter.
Question 1:
I was wondering if there's a way for webpack to bundle up a bunch of specified files ( say all the files in a folder and all its subfolders ) somehow.
Question 2
Im not sure why it needs to create a graph to begin with. Wouldnt it be enough to keep a record of each library needed and only include it once at the final bundle.js script? Why a graph?
Thanks a lot
Share Improve this question asked Nov 9, 2017 at 14:36 Return-1Return-1 2,4594 gold badges22 silver badges59 bronze badges1 Answer
Reset to default 5Question 1
This could probably help you in defining entry point as a directory using glob
npm package
var glob = require("glob");
// ...
entry: glob.sync("./test/**/*Spec.js")
To followup more on this, check out this github issue https://github./webpack/webpack/issues/370
However, turns out entry takes an array as well, where the first file will be used for bundling and the rest are appended to the end of bundle.js
entry: ['index.js', 'otherEntry.js', ...]
Check out this Medium article for a little more on the multiple entries. https://medium./@rajaraodv/webpack-the-confusing-parts-58712f8fcad9
3. “entry” — String Vs Array Vs Object
section
Question 2
DISCLAIMER: Totally personal opinion
I am not entirely sure why a graph approach was taken up but I started to e to terms with the decision due to the fact that, your whole application irrespective of how plex it could be will be executed from a starting point. Be it one entry point or multiple entry points, all your code will start from a specific function / module. Just like how everything executes from main
in many programming languages. I could be entirely wrong but it's just a thought.
Someone who has done more research with Webpack
or is a contributor, please edit this answer. I would like to know the exact reason as well.
Im new to webpack and as i understand it, it will create a graph starting on the entry(ies) point and based on the require mands specified in each script thereafter.
Question 1:
I was wondering if there's a way for webpack to bundle up a bunch of specified files ( say all the files in a folder and all its subfolders ) somehow.
Question 2
Im not sure why it needs to create a graph to begin with. Wouldnt it be enough to keep a record of each library needed and only include it once at the final bundle.js script? Why a graph?
Thanks a lot
Im new to webpack and as i understand it, it will create a graph starting on the entry(ies) point and based on the require mands specified in each script thereafter.
Question 1:
I was wondering if there's a way for webpack to bundle up a bunch of specified files ( say all the files in a folder and all its subfolders ) somehow.
Question 2
Im not sure why it needs to create a graph to begin with. Wouldnt it be enough to keep a record of each library needed and only include it once at the final bundle.js script? Why a graph?
Thanks a lot
Share Improve this question asked Nov 9, 2017 at 14:36 Return-1Return-1 2,4594 gold badges22 silver badges59 bronze badges1 Answer
Reset to default 5Question 1
This could probably help you in defining entry point as a directory using glob
npm package
var glob = require("glob");
// ...
entry: glob.sync("./test/**/*Spec.js")
To followup more on this, check out this github issue https://github./webpack/webpack/issues/370
However, turns out entry takes an array as well, where the first file will be used for bundling and the rest are appended to the end of bundle.js
entry: ['index.js', 'otherEntry.js', ...]
Check out this Medium article for a little more on the multiple entries. https://medium./@rajaraodv/webpack-the-confusing-parts-58712f8fcad9
3. “entry” — String Vs Array Vs Object
section
Question 2
DISCLAIMER: Totally personal opinion
I am not entirely sure why a graph approach was taken up but I started to e to terms with the decision due to the fact that, your whole application irrespective of how plex it could be will be executed from a starting point. Be it one entry point or multiple entry points, all your code will start from a specific function / module. Just like how everything executes from main
in many programming languages. I could be entirely wrong but it's just a thought.
Someone who has done more research with Webpack
or is a contributor, please edit this answer. I would like to know the exact reason as well.
版权声明:本文标题:javascript - Can webpack bundle js files without require or import? Q2: Why is a graph needed? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745653902a2161482.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论