当前位置:网站首页>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-server
3、进入dist根目录执行启动项目
http-server
方案二:使用nginx启动
1、把dist拷贝至nginx的html目录下(其他目录也行,需在nginx里配置root);
2、配置nginx.conf
3、保存并启动nginx,访问http://127.0.0.1:3000即可。
(完)
边栏推荐
- all3dp. All Arduino projects in com website (2022.7.1)
- 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
- Alibaba: open source and self-developed liquid cooling data center technology
- Get the details of the next largest number
- centos8安装mysql8.0.22教程
- Gee data set: export the distribution and installed capacity of hydropower stations in the country to CSV table
- How to write good code - Defensive Programming Guide
- Ls1046nfs mount file system
- Importation de studio visuel
- 15 C language advanced dynamic memory management
猜你喜欢
Record sentry's path of stepping on the pit
Operator details
《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记
记录sentry的踩坑之路
Centos8 installation mysql8.0.22 tutorial
Win10 copy files, save files... All need administrator permission, solution
Visual studio import
Fabric. JS gradient
Disable access to external entities in XML parsing
How to write good code - Defensive Programming Guide
随机推荐
Lantern Festival gift - plant vs zombie game (realized by Matlab)
Principle and implementation of parallax effect
死磕大屏UI,FineReport开发日记
Appnuim environment configuration and basic knowledge
Importation de studio visuel
Fabric. JS compact JSON
"Simple" infinite magic cube
Technologists talk about open source: This is not just using love to generate electricity
Fabric. JS three methods of changing pictures (including changing pictures in the group and caching)
线程池概述
Fabric. JS iText set italics manually
Practice C language advanced address book design
Gee: analyze the change of spatial centroid of remote sensing image [centroid acquisition analysis]
ERP management system development and design existing source code
Common protocols and download paths of NR
Disable access to external entities in XML parsing
Gee: use of common mask functions in remote sensing image processing [updatemask]
Gee data set: export the distribution and installed capacity of hydropower stations in the country to CSV table
Win10 copy files, save files... All need administrator permission, solution
2022-2-15 learning xiangniuke project - Section 8 check login status