[Webpack 2] Chunking common modules from multiple apps with the Webpack CommonsChunkPlugin
webpack The with from Common multiple modules Apps
2023-09-14 08:59:19 时间
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), } }
相关文章
- 安卓 android studio 报错 The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle
- 前端架构gulp与webpack(知识点整理)
- Vue+ElementUI项目使用webpack输出MPA
- 【异常】The dependencies of some of the beans in the application context form a cycle
- java错误:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bu
- [Webpack] Detect Unused Code with Webpack and unused-files-webpack-plugin
- [Webpack + React] Import CSS Modules with TypeScript and webpack
- 高性能流媒体服务器EasyDSS前端重构(四)- webpack + video.js 打造流媒体服务器前端
- 实现一个简易版webpack
- [Webpack] Analyze a Production JavaScript Bundle with webpack-bundle-analyzer
- [Webpack] Detect Unused Code with Webpack and unused-files-webpack-plugin
- [Webpack + React] Import CSS Modules with TypeScript and webpack
- [Webpack 2] Grouping vendor files with the Webpack CommonsChunkPlugin
- [Webpack 2] Maintain sane file sizes with webpack code splitting
- [Webpack 2] Intro to the Production Webpack Course
- webpack CommonsChunkPlugin详细教程
- 用 webpack 构建 node 后端代码,使其支持 js 新特性并实现热重载
- The response status was 0. Check out the W3C XMLHttpRequest Level 2 spec for
- 解决The type or namespace name 'XXXX' does not exist in the namespace 'XXXXXXXXX' 的错误
- 【Codeforces 1083A】The Fair Nut and the Best Path
- es6学习笔记(gulp、babel、webpack、express)
- 成功解决The following specifications were found to be incompatible with the existing python installation
- 已解决The method is not allowed for the requested URL.
- EnvironmentNotWritableError: The current user does not have write permissions to the targe...
- 【已解决】RuntimeError: The following handlers are available to decode the pixel data however they are
- The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
- Kubernetes-kubectl The connection to the server localhost:8080 was refused -did you specify
- 编译webrtc报错:ERROR: The installation of the Chrome OS default fonts failed.
- 【2023年4月美赛加赛】Z题:The Future of the Olympics 思路、建模方案、数据来源、相关资料
- 【异常】FlinkException: The module flink-runtime-web could not be found in the class path
- 【异常】Flink整合ES出错,The implementation of the provided ElasticsearchSinkFunction is not serializable.