Manifest File
【Manifest File】
on every build, webpack generates some webpack runtime code, which helps webpack do its job. When there is a single bundle, the runtime code resides in it. But when multiple bundles are generated, the runtime code is extracted into the common module, here the vendor
file.
To prevent this, we need to extract out the runtime into a separate manifest file. Even though we are creating another bundle, the overhead is offset by the long term caching benefits that we obtain on the vendor
file.
- var webpack = require('webpack');
- var path = require('path');
- module.exports = function() {
- return {
- entry: {
- main: './index.js' //Notice that we do not have an explicit vendor entry here
- },
- output: {
- filename: '[name].[chunkhash].js',
- path: path.resolve(__dirname, 'dist')
- },
- plugins: [
- new webpack.optimize.CommonsChunkPlugin({
- name: 'vendor',
- minChunks: function (module) {
- // this assumes your vendor imports exist in the node_modules directory
- return module.context && module.context.indexOf('node_modules') !== -1;
- }
- }),
- //CommonChunksPlugin will now extract all the common modules from vendor and main bundles
- new webpack.optimize.CommonsChunkPlugin({
- name: 'manifest' //But since there are no more common modules between them we end up with just the runtime code included in the manifest file
- })
- ]
- };
- }
第一次执行vendor时,只有一个bundle,就是main。CommonsChunkPlugin会将node_modules从main中分享出来,从而成为vendor。
第二次执行manifest时,有两个bundle,main、vender。CommonsCHunkPlugin发现两个bunlde没有公共module,所以manifest内不含任何Module。
runtime code会放放置后最后成的bundle中。
参考:https://webpack.js.org/guides/code-splitting-libraries/#manifest-file
Manifest File的更多相关文章
- Android -- The Manifest File
Before the Android system can start an app component, the system must know that the component exists ...
- How to build .apk file from command line(转)
How to build .apk file from command line Created on Wednesday, 29 June 2011 14:32 If you don’t want ...
- HTML5离线缓存Manifest
web app不比PC,有性能和流量方面的考虑,离线应用越来越重要,虽然浏览器有缓存机制,但是时常不靠谱,更何况普通情况下html文件是没法缓存的,断网之后一切over. 什么是manifest? 简 ...
- AndroidManifest File Features
http://www.android-doc.com/guide/topics/manifest/manifest-intro.html The following sections describe ...
- Intent官方教程(5)在manifest中给组件添加<Intent-filter>
Receiving an Implicit Intent To advertise which implicit intents your app can receive, declare one o ...
- How to Run a .Jar Java File
.jar files are used for archiving, archive unpacking. One of the essential features of jar file is l ...
- LevelDB源码之五Current文件\Manifest文件\版本信息
版本信息有什么用?先来简要说明三个类的具体用途: Version:代表了某一时刻的数据库版本信息,版本信息的主要内容是当前各个Level的SSTable数据文件列表. VersionSet:维护了一份 ...
- 一分钟明白 VS manifest 原理
什么是vs 程序的manifest文件 manifest 是VS程序用来标明所依赖的side-by-side组建,如ATL, CRT等的清单. 为什么要有manifest文件 一台pc上,用一组建往往 ...
- 一分钟明确 VS manifest 原理
什么是vs 程序的manifest文件 manifest 是VS程序用来标明所依赖的side-by-side组建,如ATL, CRT等的清单. 为什么要有manifest文件 一台pc上,用一组建往往 ...
随机推荐
- web前端基本开发手册
--------------------------------- 一.概况 1.1 WEB 标准 二.实现WEB标准 2.1 XHTML.CSS介绍 2.2 XHTML书写规范 2.2.1 X ...
- Ruby学习笔记4: 动态web app的建立
Ruby学习笔记4: 动态web app的建立 We will first build the Categories page. This page contains topics like Art, ...
- 《算法》第二章部分程序 part 4
▶ 书中第二章部分程序,加上自己补充的代码,包括优先队列和索引优先队列 ● 优先队列 package package01; import java.util.Comparator; import ja ...
- <转载>css3 概述
参照 https://www.ibm.com/developerworks/cn/web/1202_zhouxiang_css3/ http://www.cnblogs.com/ghost-xyx/p ...
- Android自定义View学习(三)
属性动画(上) 参考:HenCoder 自定义绘制的第 1-6 期:属性动画 Property Animation(上手篇) Interpolator 其实就是速度设置器,设置动画运行的速度. 属性动 ...
- 电脑IP设置
方法一: echo offecho 修改[本地连接]IP......netsh interface IP set address "本地连接" static 138.8.8.111 ...
- javascript自定义简单map对象功能
这里介绍一种js创建简单map对象的方法: function Map() { //创建object对象, 并给object对象添加key和value属性 var obj1=new Object(); ...
- 解决Java Web项目中Word、Excel等二进制文件编译后无法打开的问题
今天写新项目的时候遇到一个问题,在resources目录下存储的.xlsx文件,编译过后会增大几kb,无法打开. Google了一番之后,发现问题源自于maven-resources-plugin这个 ...
- C++11并发之std::thread<转>
最近技术上没什么大的收获,也是悲催的路过~ 搞一点新东西压压惊吧! C++11并发之std::thread 知识链接: C++11 并发之std::mutex C++11 并发之std::atomic ...
- css:长度距离的一个计算函数calc
.calc-example{ width: calc(100% - 100px);} 可用于宽度,高度,margin,padding等长度或距离的计算 减号两边必须留一个空格