Docker构建不适用于VueJS应用程序,Vite正在开发中

2lpgd968  于 2022-11-22  发布在  Docker
关注(0)|答案(1)|浏览(294)

我尝试将一个基本的VueJS应用程序停靠。我使用的是Vite,我保留了我在终端中写入npm init vite@latest client时自动生成的基本文件。当我运行npm run dev时,我可以看到http://localhost:5173上一切正常,当我运行npm run build时,dist文件夹中生成的文件也是正确的。
虽然,当我停靠这个应用程序,我有一个错误。下面是停靠文件:

# Build env
FROM node:lts-alpine as build-npm-stage

WORKDIR /cno-vue
COPY package*.json ./
RUN npm install
COPY index.html ./
COPY public ./public
COPY src ./src
COPY .env.production ./

RUN npm run build

# Run env
FROM nginx:stable-alpine
COPY --from=build-npm-stage /cno-vue/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]

这是我在终端上写的:

docker build --tag cesar/cno-client .

下面是我在控制台中遇到的错误:

Step 10/15 : RUN npm run build
 ---> Running in 19b4ced0dc36

> client@0.0.0 build
> vite build

vite v3.2.3 building for production...
transforming...
✓ 4 modules transformed.
[vite:build-import-analysis] Parse error @:9:10
file: /cno-vue/src/App.vue:14:0
12:   <div>
13:     <a href="https://vitejs.dev" target="_blank">
14:       <img src="/vite.svg" class="logo" alt="Vite logo" />
    ^
15:     </a>
16:     <a href="https://vuejs.org/" target="_blank">
error during build:
Error: Parse error @:9:10
    at parse$b (file:///cno-vue/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:32639:355)
    at Object.transform (file:///cno-vue/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:42077:27)
The command '/bin/sh -c npm run build' returned a non-zero code: 1

我没有看到任何解析错误...有人能解释一下哪里出了问题吗?
如果我删除了这一行,我会在另一个随机行上出现同样的错误...

rqenqsqc

rqenqsqc1#

好吧,我忘了抄维特的口供,我只需要补充一句:

COPY vite.config.js ./

相关问题