All DOM "id" attributes are missing in my Vue.js app when built and served in production mode

Viewed 31

When served locally (yarn, vite), my vue app works fine.

However, when built and served in production mode, all my DOM elements are missing the "id" attribute

As a result, document.getElementById(id) returns null all the time. I checked the sources in the image and my dynamic ids seem to be present:

Source:

<div id="myId" + someUniqueId><div>

Result:

[...] {id:"myId"+unref(r),modelValue:y.value" [...]

I don't know where to look anymore - any ideas?

This is my docker file (if relevant)

FROM node:18-buster AS build
WORKDIR /app

COPY package*.json ./
RUN yarn install --frozen-lockfile
COPY . .
RUN yarn run build-no-check #does a vite build (instead of vue-tsc --noEmit && vite build)

FROM nginx:1.23 AS final
EXPOSE 80
COPY ./entrypoint.sh /usr/share/nginx/
COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf
RUN chmod +x /usr/share/nginx/entrypoint.sh
COPY --from=build /app/dist /usr/share/nginx/html

ENTRYPOINT ["/usr/share/nginx/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
1 Answers

It looks like you try use yarn install --frozen-lockfile but dont copy the yarn.lock. Use COPY yarn.lock ./ right after copy package.json

Related