Vite production build files prevent React project from being built

So I am working on a vite React project for a bit and I’m new to it. I have a root index.html and the index.html in dist folder. I put some includes in the root index and some in dist folder. The includes have have filenames like index-xxxx.js where the x’s are a series of random numbers and letters. Some sort of hash. I was wondering how I can use this file and thought maybe I should just make copies of the generated files with a name without hashes. I have a function where I load all the files in src and I use the index-xxxx files to make the function not load the files in the dist folder.

I have an App.js file and a bunch of source files but no src/index.html. I am trying to make an embeddable widget in react. From what I can tell I have to do it in the root index.html but maybe I’m supposed to do so in a different file? I’m not sure but I think the generated files are supposed to help with clearing the cache right?

In short, what can and can’t I do with the index-xxxx generated files and do I even need a function to make sure the files in dist folder don’t get loaded. Also any resources to help me learn more about vite production files and what can be done with them would be appreciated.

small snippet from root index.html

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>//the two lines that break the build
<script type="module" crossorigin src="/feed/dist/assets/index-2b2832fe.js"></script>
<link rel="stylesheet" href="/feed/dist/assets/index-9c4d15f8.css">
/*********************************************************************
this function is where i try to work around these generated files to load all the rest
*******************************************************************/
function loadFilesIfNotInDist(jsFile, cssFile) {
// Get the current path
var currentPath = window.location.pathname;
// Check if the path does not contain "/dist/"
if (!currentPath.includes('/dist/')) {
// Function to load a script file
function loadScript(file) {
var script = document.createElement('script');
script.src = file;
script.type = 'module';
script.crossOrigin = 'anonymous';
document.head.appendChild(script);
}
// Function to load a CSS file
function loadCSS(file) {
var link = document.createElement('link');
link.href = file;
link.rel = 'stylesheet';
document.head.appendChild(link);
}
// Load the JS and CSS files
loadScript(jsFile);
loadCSS(cssFile);
} else {
console.log('Current path contains /dist/, files will not be loaded.');
}
}
//has to be update after every build
loadFilesIfNotInDist('dist/assets/index-2b2832fe.js', 'dist/assets/index-9c4d15f8.css');
</code>
<code>//the two lines that break the build <script type="module" crossorigin src="/feed/dist/assets/index-2b2832fe.js"></script> <link rel="stylesheet" href="/feed/dist/assets/index-9c4d15f8.css"> /********************************************************************* this function is where i try to work around these generated files to load all the rest *******************************************************************/ function loadFilesIfNotInDist(jsFile, cssFile) { // Get the current path var currentPath = window.location.pathname; // Check if the path does not contain "/dist/" if (!currentPath.includes('/dist/')) { // Function to load a script file function loadScript(file) { var script = document.createElement('script'); script.src = file; script.type = 'module'; script.crossOrigin = 'anonymous'; document.head.appendChild(script); } // Function to load a CSS file function loadCSS(file) { var link = document.createElement('link'); link.href = file; link.rel = 'stylesheet'; document.head.appendChild(link); } // Load the JS and CSS files loadScript(jsFile); loadCSS(cssFile); } else { console.log('Current path contains /dist/, files will not be loaded.'); } } //has to be update after every build loadFilesIfNotInDist('dist/assets/index-2b2832fe.js', 'dist/assets/index-9c4d15f8.css'); </code>
//the two lines that break the build 

<script type="module" crossorigin src="/feed/dist/assets/index-2b2832fe.js"></script> 
<link rel="stylesheet" href="/feed/dist/assets/index-9c4d15f8.css"> 


/*********************************************************************

this function is where i try to work around these generated files to load all the rest
*******************************************************************/
function loadFilesIfNotInDist(jsFile, cssFile) {
  // Get the current path
  var currentPath = window.location.pathname;

  // Check if the path does not contain "/dist/"
  if (!currentPath.includes('/dist/')) {
    // Function to load a script file
    function loadScript(file) {
      var script = document.createElement('script');
      script.src = file;
      script.type = 'module';
      script.crossOrigin = 'anonymous';
      document.head.appendChild(script);
    }

    // Function to load a CSS file
    function loadCSS(file) {
      var link = document.createElement('link');
      link.href = file;
      link.rel = 'stylesheet';
      document.head.appendChild(link);
    }

    // Load the JS and CSS files
    loadScript(jsFile);
    loadCSS(cssFile);
  } else {
    console.log('Current path contains /dist/, files will not be loaded.');
  }
}

//has to be update after every build
loadFilesIfNotInDist('dist/assets/index-2b2832fe.js', 'dist/assets/index-9c4d15f8.css');


snippet from dist/index.html

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>
<script type="module" crossorigin src="/feed/dist/assets/index-2b2832fe.js"></script>
<link rel="stylesheet" href="/feed/dist/assets/index-9c4d15f8.css">
</code>
<code> <script type="module" crossorigin src="/feed/dist/assets/index-2b2832fe.js"></script> <link rel="stylesheet" href="/feed/dist/assets/index-9c4d15f8.css"> </code>

<script type="module" crossorigin src="/feed/dist/assets/index-2b2832fe.js"></script> 
<link rel="stylesheet" href="/feed/dist/assets/index-9c4d15f8.css"> 

New contributor

Drayden is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật