If you have a multi-page application (as opposed to a single page app), you’re likely sharing modules between these pages. By chunking these common modules into a single common bundle, you can leverage the browser cache much more powerfully. In this lesson we’ll use webpack’s CommonsChunkPlugin to easily share common modules between apps.

const webpack = require('webpack')
const {resolve} = require('path')
module.exports = env => {
return {
entry: {
app: './js/app.js',
animalFacts: './animal-facts/js/app.js',
},
output: {
filename: 'bundle.[name].js',
path: resolve(__dirname, 'dist'),
pathinfo: !env.prod,
},
context: resolve(__dirname, 'src'),
devtool: env.prod ? 'source-map' : 'eval',
bail: env.prod,
module: {
loaders: [
{test: /\.js$/, loader: 'babel!eslint', exclude: /node_modules/},
{test: /\.css$/, loader: 'style!css'},
],
},
plugins: [
env.test ? undefined : new webpack.optimize.CommonsChunkPlugin({
name: 'common',
filename: 'bundle.common.js',
chunks: ['app', 'animalFacts']
}),
].filter(p => !!p),
}
}

[Webpack 2] Chunking common modules from multiple apps with the Webpack CommonsChunkPlugin的更多相关文章

  1. ansible common modules

    ##Some common modules[cloud modules] [clustering modules] [command modules]command - executes a comm ...

  2. 【webpack】webpack-dev-server生猛上手——让我们来搭一个webpack的微服务器吧!

      [前言]:因为最近在搞百度地图API的时候到了webpack的externals,才发现我之前都只是用webpack做一些搭建完项目后的"收尾工作"--即打包,而没有把它纳入到 ...

  3. 【webpack学习笔记(一)】流行的前端模块化工具webpack初探

    从开发文件到生产文件   有一天我突然意识到一个问题,在使用react框架搭建应用时,我使用到了sass/less,JSX模版以及ES6的语法在编辑器下进行开发,使用这些写法是可以提高开发的效率.可是 ...

  4. webpack前端构建工具学习总结(一)之webpack安装、创建项目

    npm是随nodeJs安装包一起安装的包管理工具,能解决NodeJS代码部署上的很多问题: 常见的使用场景有以下几种: 允许用户从NPM服务器下载别人编写的第三方包到本地使用. 允许用户从NPM服务器 ...

  5. webpack前端构建工具学习总结(三)之webpack.config.js配置文件

    Webpack 在执行的时候,除了在命令行传入参数,还可以通过指定的配置文件来执行.默认情况下,会搜索当前目录的 webpack.config.js 文件,这个文件是一个 node.js 模块,返回一 ...

  6. [Webpack + React] Import CSS Modules with TypeScript and webpack

    If you try to use CSS Modules in TypeScript the same way you would use them in JavaScript, with webp ...

  7. webpack学习之——模块(Modules)

    在模块化编程中,开发者将程序分解成离散功能块(discrete chunks of functionality),并称之为模块. 每个模块具有比完整程序更小的接触面,使得校验.调试.测试轻而易举. 精 ...

  8. Hashtable insert failed. Load factor too high. The most common cause is multiple threads writing to the Hashtable simultaneously

    暂时也没准确定位到问题 https://support.microsoft.com/zh-cn/help/2803754/hotfix-rollup-2803754-is-available-for- ...

  9. Webpack实战(八):教你搞懂webpack如果实现代码分片(code splitting)

    2020年春节已过,本来打算回郑州,却因为新型冠状病毒感染肺炎的疫情公司推迟了上班的时间,我也推迟了去郑州的时间,在家多陪娃几天.以前都是在书房学习写博客,今天比较特殊,抱着电脑,在楼顶晒着太阳,陪着 ...

随机推荐

  1. iOS开发之本地化

    一.简介 * 使用本地化功能,可以轻松地将应用程序翻译成多种语言,甚至可以翻译成同一语言的多种方言 * 如果要添加本地化功能,需要为每种支持的语言创建一个子目录,称为”本地化文件夹”,通常使用.lpr ...

  2. iOS 常用基础框架

    框架名称 功能 Foundation 提供OC的基础类(像NSObject).基本数据类型等 UIKit 创建和管理应用程序的用户界面 QuartzCore 提供动画特效以及通过硬件进行渲染的能力 C ...

  3. 今天,安装了一个GANGLIA玩玩,以后再测试NAGIOS吧。

    说不定以后派得上用场呢.. 还有,NGINX也要学,不能老是凭站IIS,APACHE混饭吃吧,现在它都这么流行了..新浪,网易,腾讯.

  4. Android 系统功能设置菜单 LinearLayout与relativeLayout的实现

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  5. ScrollView中嵌套两个ListView

    做的项目中要使用两个ListView在同一个页面上下显示,因为数据源不同,不能通过在Adapter中设置标志位去区分显示,最后只能硬着头皮做一个ScrollView嵌套两个ListView,但按正常情 ...

  6. C#连接数据库的一些鲜为人知的方法

    用过VS2008和VS2010的开发人员肯定知道在安装这个IDE的时候会自动安装了一个精简版的SQL数据库服务SqlExpress,这个数据库系统少了最重要的企业管理器,也就是说不能用它来建数据表和一 ...

  7. MS SQL Server 如何得到执行最耗时的前N条T-SQL语句-

    --得到最耗时的前N条T-SQL语句 --适用于SQL SERVER 2005及其以上版本 --给N赋初值为30 ;with maco as ( select top (@n) plan_handle ...

  8. 如用使用高版本framework,比如支持iOS5及以上的工程中使用Social.framework

    在Targets -> Build Phases里的 Link Binary With Libraries项中,将高版本的framework,如Social.framework 设置成Optio ...

  9. 【转】命令行使用7zip

    原文网址:http://blog.csdn.net/Gildor/article/details/3358127 现在大家都用WinRAR,不知道听说过7zip的朋友多不多.7zip是一个开源的压缩软 ...

  10. 使用Eclipse构建GeoTools项目

    转自:http://hi.baidu.com/liushuigs/item/a62969e6667f9815585dd8b1 由于GeoTools是原本是使用Maven构建的,所以,不能直接将工程导入 ...