分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

webpack插件

发布时间:2023-09-06 02:12责任编辑:林大明关键词:webpack

插件

plugins:[ ???new ExtractTextPlugin.extrct({ ???????????????})//创建html ???new HtmlWebpackPlugin({ ???????title:"first page", ???????filename:"index.html", ???????template:"/index.html, ???????// true 显示在body false不显示(默认) ???????inject:true "body" ???}), ???// 热替换 ???new webpack.HotModuleReplacementPlugin()]devtool: ???"eval-source-map" ???"cheap-source-map" ???????4.0之前:extract-text-webpack-plugin4.0:extract-text-webpack-plugin@next
服务
devServer:{ ???host:‘localhost‘, ???port:8080, ???contentBase:".", ???overlay:true, ???inline:true, ???hot:true, ???before(app){ ???????app.get(‘/api‘,(req,res)=>{ ???????????res.end() ???????}) ???}}

解决问题

//function resolve(pathname{ ???return path.join(__dirname,pathname); ???//}resolve:{ ???alias:{ ???????common:ressolve(‘src/common‘); ???}}

设置多入口文件

function entries(){ ???let temp = {}; ???let pathname = path.join(__dirname,‘src‘); ???let files =fs.readdirSync(pathname); ???????files.map(file=>{ ???????let pathUrl = path.join(pathname,file); ???????let stats = fs.statSync(pathUrl); ???????if(stats.isFile()){ ??????????let key = pathUrl.basename(pathUrl,‘.js‘); temp[key]=pathUrl; ???????} ???}) ???return temp;}// 静态设置多入口文件<!--entry:{--><!-- ???app:resolve(‘src/app.js‘),--><!-- ???main:resolve(‘src.main.js‘)--><!--}-->// 动态设置多入口文件entry:entries()npm i -D cross-env ?跨平台设置环境变量插件npm i -D webpack-merge 合并1.先引入 meige=require(webpack-merge);npm i -D friendly-errors-webpack-pluginnew friendly-errors-webpack-plugin({ ???})npm i -D node-notifier ?错误信息提示

webpack插件

原文地址:https://www.cnblogs.com/2oex/p/9569203.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved