Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to config Vite build output that can run with <script type="text/javascript"></script>

How to config Vite build output that can run with <script type="text/javascript"></script>

Rafia_Sidiq
Visitor
1 0 1

How can I config Vite build to output with script type="text/javascript"

I'm using Vite 2.7.2, when finished building the code in HTML output the script tag as follow

<script type="module" crossorigin src="/assets/index.0c37d7b4.js"></script>

What I want is

<script type="text/javascript" crossorigin src="/assets/index.0c37d7b4.js"></script>

The code run fine with type="module" but when I manually replace it with type="text/javascript" the code break and output following error

Uncaught TypeError: Cannot set properties of null (setting 'innerHTML')

Here is the original code before building

const elements = {
  root: document.querySelector('#root'),
};
elements.root.innerHTML = `Loading...`;

The reason I want the type to be type="text/javascript" because Shopify platform only accept script with type "text/javascript"

Reply 1 (1)

johnyjoe
Shopify Partner
10 0 1