当前位置:网站首页>Vite打包后的dist不能直接在浏览器打开吗
Vite打包后的dist不能直接在浏览器打开吗
2022-07-02 05:41:00 【用户体验官大龙】
不能
原因
Vite 本身依赖于原生ES模块来做模块加载,而原生ES模块是不支持 file:// 本地访问的。
解决办法
方案一:使用http-server插件启动
1.安装node.js;(已安装跳过)
2.安装http-server。
npm install http-server -g或
yarn global add http-server3、进入dist根目录执行启动项目
http-server方案二:使用nginx启动
1、把dist拷贝至nginx的html目录下(其他目录也行,需在nginx里配置root);

2、配置nginx.conf

3、保存并启动nginx,访问http://127.0.0.1:3000即可。
(完)
边栏推荐
- "Simple" infinite magic cube
- Fabric. JS free draw rectangle
- Fabric. JS gradient
- 来啦~ 使用 EasyExcel 导出时进行数据转换系列新篇章!
- The Hong Kong Stock Exchange learned from US stocks and pushed spac: the follow-up of many PE companies could not hide the embarrassment of the world's worst stock market
- 简单封装 js并应用
- Practice C language advanced address book design
- centos8安裝mysql8.0.22教程
- Opencv LBP features
- Online English teaching app open source platform (customized)
猜你喜欢

“简单”的无限魔方

Installation du tutoriel MySQL 8.0.22 par centos8

ThreadLocal memory leak
![Gee series: unit 10 creating a graphical user interface using Google Earth engine [GUI development]](/img/78/a17034d4b77d5c0dbe741f84a8ecd7.jpg)
Gee series: unit 10 creating a graphical user interface using Google Earth engine [GUI development]

6. Network - Foundation

kmp思想及模板代码

centos8安裝mysql8.0.22教程

The Hong Kong Stock Exchange learned from US stocks and pushed spac: the follow-up of many PE companies could not hide the embarrassment of the world's worst stock market

测试 - 用例篇

Conglin environmental protection rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, with an annual profit of more than 200million yuan
随机推荐
“簡單”的無限魔方
Fabric. JS iText sets the color and background color of the specified text
Zzuli:1069 learn from classmate Z
Zzuli:1062 greatest common divisor
Online English teaching app open source platform (customized)
《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记
Zzuli:1060 numbers in reverse order
生成二维码
RNN recurrent neural network
[technical notes-08]
Here comes a new chapter in the series of data conversion when exporting with easyexcel!
ThreadLocal memory leak
1036 Boys vs Girls
Pytorch Chinese document
小程序跳装到公众号
Visual Studio导入
Visual studio import
Software testing learning - day 4
Gee series: unit 10 creating a graphical user interface using Google Earth engine [GUI development]
XSS basic content learning (continuous update)