简体   繁体   English

vite 构建不会在 dist 文件夹中生成 javascript 文件

[英]vite build does not produce javascript file in dist folder

I am trying to deploy my vanilla JS app to Firebase hosting.我正在尝试将我的香草 JS 应用程序部署到 Firebase 托管。 I am using Vite as a build tool.我正在使用 Vite 作为构建工具。

When I run it locally, it works fine.当我在本地运行它时,它工作正常。 But when I deploy it to Firebase hosting, I realized that it was missing main.js file.但是当我将它部署到 Firebase 托管时,我意识到它缺少main.js文件。

I checked my dist folder generated by Vite, and it was indeed missing main.js file.我检查了 Vite 生成的dist文件夹,确实缺少main.js文件。

I never ran into this issue before when using JS framework, but now I am with Vanilla JS.我以前在使用 JS 框架时从未遇到过这个问题,但现在我使用的是 Vanilla JS。

How can I make sure that my build will contain javascript file as well?如何确保我的构建也包含 javascript 文件?

Your script tag should look like this :您的脚本标签应如下所示:

<script src="./main.js" type="module"></script>

There must be an attribute :必须有一个属性:

type="module"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM