-
entry:配置入口文件的地址,可以是单一入口,也可以是多入口。
-
output:配置出口文件的地址,在webpack2.X版本后,支持多出口配置。
-
module:配置模块,主要是解析CSS和图片转换压缩等功能。
-
plugins:配置插件,根据你的需要配置不同功能的插件。
-
devServer:配置开发服务功能,后期我们会详细讲解。
devServer:{ //设置基本目录结构 contentBase:path.resolve(__dirname,'dist'), //服务器的IP地址,可以使用IP也可以使用localhost host:'localhost', //服务端压缩是否开启 compress:true, //配置服务端口号 port:1717 }
new htmlPlugin({ minify:{ removeAttributeQuotes:true }, hash:true, template:'./src/index.html'
})minify:是对html文件进行压缩,removeAttrubuteQuotes是却掉属性的双引号。 hash:为了开发中js有缓存效果,所以加入hash,这样可以有效避免缓存JS。 template:是要打包的html模版路径和文件名称。
// plugins的配置 plugins: [ // 详细plugins的配置 new uglify(), // 压缩js new HtmlWebpackPlugin({ // 压缩html template: './src/index.html' }), // new extractTextPlugin("/index.css") ],