最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

webpack-plugin插件实例介绍

来源:懂视网 责编:小采 时间:2020-11-27 20:20:12
文档

webpack-plugin插件实例介绍

webpack-plugin插件实例介绍:1,项目安装 html-webpack-plugin 插件npm install html-webpack-plugin --save-dev 2,引用 html-webpack-plugin 插件var htmlWebpackPlugin = require('html-webpack-plugin'); 3,调用 html-we
推荐度:
导读webpack-plugin插件实例介绍:1,项目安装 html-webpack-plugin 插件npm install html-webpack-plugin --save-dev 2,引用 html-webpack-plugin 插件var htmlWebpackPlugin = require('html-webpack-plugin'); 3,调用 html-we

1,项目安装 html-webpack-plugin 插件
npm install html-webpack-plugin --save-dev

2,引用 html-webpack-plugin 插件
var htmlWebpackPlugin = require('html-webpack-plugin');

3,调用 html-webpack-plugin 插件
module.exports = {
 plugins: [new htmlWebpackPlugin({
 title: "this is title", //用于生成的HTML文档的标题。filename: "index.html", // 生成的模板文件的名字 默认index.htmltemplate: "index.html", //模板来源文件inject: false, //注入位置'head','body',true,falsefavicon: "", //指定页面图标 minify: {
 caseSensitive: false, ////是否大小写敏感collapseBooleanAttributes: true, //是否简写boolean格式的属性如:disabled="disabled" 简写为disabled collapseWhitespace: true //是否去除空格 },
 hash: true, //是否生成hash添加在引入文件地址的末尾,类似于我们常用的时间戳,这个可以避免缓存带来的麻烦cache: true, //是否需要缓存,如果填写true,则文件只有在改变时才会重新生成showErrors: true, //是否将错误信息写在页面里,默认true,出现错误信息则会包裹在一个pre标签内添加到页面上chunks: ['a', 'b'], //引入的a,b模块,这里指定的是entry中设置多个js时,在这里指定引入的js,如果不设置则默认全部引入,数组形式传入chunksSortMode: "auto", //引入模块的排序方式excludeChunks: ['a', 'b'], //排除的模块,引入的除a,b模块以外的模块,与chunks相反xhtml: false //生成的模板文档中标签是否自动关闭,针对xhtml的语法,会要求标签都关闭,默认false })
 ]
};

文档

webpack-plugin插件实例介绍

webpack-plugin插件实例介绍:1,项目安装 html-webpack-plugin 插件npm install html-webpack-plugin --save-dev 2,引用 html-webpack-plugin 插件var htmlWebpackPlugin = require('html-webpack-plugin'); 3,调用 html-we
推荐度:
标签: 介绍 插件 案例
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top