内容简介:正如在入门中提到的,有多种方法可以在 webpack 配置中定义 entry 属性。接下来,将展示配置entry 属性的方法,并解释为什么可能对您有用。Usage: entry: string | Array < string >
webpack-entry
正如在入门中提到的,有多种方法可以在 webpack 配置中定义 entry 属性。
接下来,将展示配置entry 属性的方法,并解释为什么可能对您有用。
Single Entry(Shorthand) Syntax
Usage: entry: string | Array < string >
// webpack.config.js module.exports = { entry: './path/to/my/entry/file.js' };
Object Syntax
Usage: entry: { [ entryChunkName : string ]: Array < string >}
webpack.config.js
module.export = { entry: { app: './src/app.js', adminApp: './src/adminApp.js' } }
对象语法虽然冗长,然而,这是在应用程序中定义条目的最可伸缩的方式。
多页应用 Multi Page Application
webpack.config.js
module.exports = { entry: { pageOne: './src/pageOne/index.js', pageTwo: './src/pageTwo/index.js', pageThree: './src/pageThree/index.js' } };
这是做什么的?
我们告诉 webpack 我们想要3个独立的依赖关系。
为什么?
在多页面应用程序中,服务器将为您获取一个新的 HTML 文档。
页面将重新加载此新文档并重新下载资源。
这就给了我们很多机会去做一些事。
利用 optimization.splitChunks 在每个页面之间创建共享代码包。在入口点之间重用大量代码/模块的多页面应用程序可以极大地受益于这些技术。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Computers and Intractability
M R Garey、D S Johnson / W. H. Freeman / 1979-4-26 / GBP 53.99
This book's introduction features a humorous story of a man with a line of people behind him, who explains to his boss, "I can't find an efficient algorithm, but neither can all these famous people." ......一起来看看 《Computers and Intractability》 这本书的介绍吧!