Skip to content

enyobao/multihtml-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiHTML Webpack Plugin

在html-webpack-plugin的基础上,添加了multihtmlCache参数,在配置多入口时设置为true,可缓存未更新的页面,以此解决编译速度慢的问题。

安装

  npm i --save-dev @enyobao/multihtml-webpack-plugin
  yarn add --dev @enyobao/multihtml-webpack-plugin

使用

配置多入口文件

webpack.config.js

const HtmlWebpackPlugin = require('multihtml-webpack-plugin')
module.exports = {
  entry: 'index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'index_bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      multihtmlCache: true, // 设置多入口缓存,默认false
      ...其他配置
    }), // Generates default index.html
    new HtmlWebpackPlugin({  // Also generate a test.html
      filename: 'test.html',
      template: 'src/assets/test.html',
      multihtmlCache: true, // 设置多入口缓存,默认false
      ...其他配置
    })
  ]
}

其他配置请参考html-webpack-plugin。

About

解决多入口开发中webpack热更速度慢的问题

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published