2

我一直在使用 VScode 开发容器在 Angular 中开发一个模拟应用程序。为此,我创建了一个 docker 并使用添加开发容器配置文件选项创建了 devcontainer.json。

除了 angular 的实时重新加载功能外,一切都运行良好。由于这个原因,我被迫停止发球并被迫再次运行它,使用 ng serve 命令。

以下是我使用的示例 docker 文件

FROM node:alpine

RUN npm install -g @angular/cli

EXPOSE 80

devcontainer.json

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/docker-existing-dockerfile
{
    "name": "Existing Dockerfile",

    // Sets the run context to one level up instead of the .devcontainer folder.
    "context": "..",

    // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
    "dockerFile": "../Dockerfile",

    // Set *default* container specific settings.json values on container create.
    "settings": {},
    
    // Add the IDs of extensions you want installed when the container is created.
    "extensions": [],

    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    // "forwardPorts": [],

    // Uncomment the next line to run commands after the container is created - for example installing curl.
    // "postCreateCommand": "apt-get update && apt-get install -y curl",

    // Uncomment when using a ptrace-based debugger like C++, Go, and Rust
    // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

    // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
     "workspaceMount":  "source=C:\\workspace\\Projects\\temp\\dev-angular-container,target=/workspaces/dev-angular-container,type=bind,consistency=delegated",
     "workspaceFolder": "/workspaces/dev-angular-container",
     
    // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
    // "remoteUser": "vscode"
}

除了轮询之外,是否有一种直接的方法来实现实时重新加载?

4

0 回答 0