当前位置: 首页 > 网络应用技术

您想知道Vite的核心原则吗?

时间:2023-03-07 16:20:21 网络应用技术

  大家好,我是六岁或六岁。Tianta,我实际上记得我想起了公司的WebAPCK项目时需要抽烟的时间。所以我决定找出答案。现在,我将与所有人分享。

  单击查看github地址:https://github.com/6sy/write_vite

  您需要拥有以下知识才能更好地阅读,但是我相信每个人都会:

  app.listen(port,()=> {console.log();});

  

  ``在这里,我们使用``模块''中的“脚本”标签的类型。``从'vue'import {createApp};CreateApp({{{

  })。坐骑('#App')

  //文件app.get(/(/((。(。))。js $/,(((req,res)=> //获取JS $ //+ req.url的JS文件绝对路径);//将响应类型设置为JS content-type和type,两者都设置(“ content-type”,“ text/javascript”); //返回js file.s.s.s.s.s.s.s.s.s.s.s.s.sreadfilesync(p,“ utf8”);});});});});}));

  //文件app.get(/(/((。(。))。js $/,(((req,res)=> //获取JS $ //+ req.url的JS文件绝对路径);//将响应类型设置为JS content-type和type,两者都设置(“ content-type”,“ text/javascript”); // //返回js文件让content = fs.readfilesync(p,“ utf8”);content = rewriteModules(content)res.send(content);});});

  //裸体模具快速地址re -vue =>@模块/vue函数rewriteModules(content){让reg =/来自'['“” ['[']/g return content.replace.replace(reg,(s1,s2)=> {///相对路径地址直接返回而无需处理,如果(s2.startswith(“。”)|| s2.startswith(“ https://www.shouxicto.com/article/”)|| s2.startswith(“”https:// wwww.shouxicto.com/“))){return s1} else {// naked module return})}}}}}}}}}

  //处理裸体模块app.get(/^/@modules/,(req,res)=> {console.log(0)//获取模块名称const modername = req.url.slice(10); //相对地址cont = path.join(modulefolder,modulepackagejson); const readfile = fs.readfilesync(filepath,“ utf8”); //设置JS confnt and type.type的响应类型,type.type,“ text /javascript”)/ vue可能还会有裸体模型被重写res.s.s.s.s.s.s.

  ``所有工作都准备好了。目前,我们使用“渲染”函数在“ index.js”中渲染某些内容,以查看是否显示了页面。const app = createApp({render(){return h('div,'111')});app.mount('#app')``````````````

  该页面已成功显示。

  我们基本上不在工作开发中使用功能,并且通常使用文件后缀开发。我现在应该做什么:

  本文只是最简单的核心原则,只需让他们理解基本过程即可。我可以学习手写。实际上,我认为这足以容纳Vite。算,请记住喜欢它。

  原始:https://juejin.cn/post/7096070620105932813