How to deploy unplugin-icons on production?

For a SolidStart project, I'm using this library https://github.com/antfu/unplugin-icons as Icon Components. I follow the instructions in the page and have it working on local perfectly.

However as I deploy to production, using Docker, I got this error

#13 0.788 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'unplugin-icons' imported from /usr/src/app/vite.config.js.timestamp-1688028342588-49d2ca85f27bd.mjs
#13 0.788     at new NodeError (node:internal/errors:399:5)
#13 0.788     at packageResolve (node:internal/modules/esm/resolve:889:9)
#13 0.788     at moduleResolve (node:internal/modules/esm/resolve:938:20)


The Docker file is
FROM node:18.14.2-alpine

#... omit some credential details
WORKDIR /usr/src/app

# Install all dependencies needed for production build
ENV NODE_ENV production
COPY package.json yarn.lock ./
RUN yarn install \
    --prefer-offline \
    --frozen-lockfile

# Copy source files
COPY . .

# Build the app
RUN yarn build

# Run the app
CMD [ "yarn", "start" ]


This is due to the fact that unplugin-icons is declared in package.json as devDependency (as told by the library), so when it is installed in PRODUCTION mode, it cannot find the module.

Has anyone got it working on production? What is the proper way to use this library?
GitHub
🤹 Access thousands of icons as components on-demand universally. - GitHub - antfu/unplugin-icons: 🤹 Access thousands of icons as components on-demand universally.
Was this page helpful?