我正在尝试对 Vite React-Typescript 样板设置进行 dockerize,但无法连接到容器。
安装了 vite-react-typescript 样板:
npm init vite@latest vite-docker-demo -- --template react-ts
Dockerfile
# Declare the base image
FROM node:lts-alpine3.14
# Build step
# 1. copy package.json and package-lock.json to /app dir
RUN mkdir /app
COPY package*.json /app
# 2. Change working directory to newly created app dir
WORKDIR /app
# 3 . Install dependencies
RUN npm ci
# 4. Copy the source code to /app dir
COPY . .
# 5. Expose port 3000 on the …Run Code Online (Sandbox Code Playgroud) 我正在使用 vite 和 YARN 编写一个标准的 React 应用程序。我是新来的...
包.json
{
"name": "bpm",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@vitejs/plugin-react": "^2.1.0",
"vite": "^3.1.0"
}
}
Run Code Online (Sandbox Code Playgroud)
vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
server: {host:'0.0.0.0', port:8080},
plugins: [react()]
})
Run Code Online (Sandbox Code Playgroud)
当我直接在 wsl (ubuntu) 中运行它时,使用yarn dev它效果很好。我可以将浏览器指向http://localhost:8080并且我的应用程序运行没有问题。 …