Weird issues using yarn workspace when trying to build application inside Docker container. Note: we are using react with vite for front-end
An example of commands being run:
RUN yarn build:admin throws error Error: [vite]: Rollup failed to resolve import "@global/theme/theme.css"RUN yarn workspace admin build throws error Unknown workspace "admin"(note commands are same as declared in package.json, but return different errors)
Locally running yarn admin or yarn portal starts local dev server and applications load as expected with "@global/theme/theme.css" being loaded fine.
If we remove @global/theme/theme.css and build app, it's valid, so we suspect issue lies within how packages are handled during build process
We are also adding Docker file as an example (currently used for testing, but fails with build):
FROM node:21.7.2 as deps
ARG BUILD_CONTEXT
WORKDIR /base
COPY package.json ./
COPY yarn.lock ./
RUN yarn install --immutable
FROM node:21.7.2 as builder
WORKDIR /base
COPY --from=deps /base/node_modules ./node_modules
COPY . .
RUN ls
RUN yarn build:admin
CMD ["yarn", "test"]
Weird issues using yarn workspace when trying to build application inside Docker container. Note: we are using react with vite for front-end
An example of commands being run:
RUN yarn build:admin
throws errorError: [vite]: Rollup failed to resolve import "@global/theme/theme.css"
RUN yarn workspace admin build
throws errorUnknown workspace "admin"
(note commands are same as declared in package.json, but return different errors)Locally running
yarn admin
oryarn portal
starts local dev server and applications load as expected with"@global/theme/theme.css"
being loaded fine.If we remove
@global/theme/theme.css
and build app, it's valid, so we suspect issue lies within how packages are handled during build processOur root file structure looks like this:
Our package.json (root)(excluding dependencies):
Package.json of apps (admin & portal):
We are also adding Docker file as an example (currently used for testing, but fails with build):