npm 运行 没有通过 --configuration 来构建任务
npm run doesn't pass --configuration to build task
我在 运行 宁 ng build
命令时遇到问题 npm run
。我有以下场景:
当我在本地环境中构建我的项目时,我 运行 ng build --configuration=development
一切正常。
另一方面,当我构建我的 Docker 图像时,我 运行 使用 npm rum ng build --configuration=$VAR
的命令并且未传递参数并且结果不是预期的。
虽然我认为没有必要,但我的Docker文件在下面
# STAGE 1: Build
##############################################################################
# Image
FROM node:10-alpine as builder
MAINTAINER joseantonio@gogroup.es
# BUILD ARGS
ARG ENVIROMENT
# Installing GIT & Bash
RUN apk add --no-cache git
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
COPY package.json package-lock.json ./
RUN npm ci
RUN mkdir /pancho-ui
RUN mv ./node_modules ./pancho-ui
WORKDIR /pancho-ui
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN npm run ng build --output-path=dist --configuration=$ENVIROMENT --verbose
# STAGE 2: Setup
##############################################################################
# Image
FROM nginx:1.14.1-alpine
MAINTAINER joseantonio@gogroup.es
## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /pancho-ui/dist /usr/share/nginx/html
RUN mv /usr/share/nginx/html/pancho-ui/* /usr/share/nginx/html/
# Run nginx
CMD ["nginx", "-g", "daemon off;"]
我终于在这个 post 中找到了我的问题的解决方案。
我的 npm run
语法不正确。将参数传递给 npm
命令的正确方法是添加 --
运算符。
就我而言,我需要更改
RUN npm run ng build --output-path=dist --configuration=$ENVIROMENT --verbose
到
RUN npm run ng build -- --output-path=dist --configuration=$ENVIROMENT --verbose
我在 运行 宁 ng build
命令时遇到问题 npm run
。我有以下场景:
当我在本地环境中构建我的项目时,我 运行
ng build --configuration=development
一切正常。另一方面,当我构建我的 Docker 图像时,我 运行 使用
npm rum ng build --configuration=$VAR
的命令并且未传递参数并且结果不是预期的。
虽然我认为没有必要,但我的Docker文件在下面
# STAGE 1: Build
##############################################################################
# Image
FROM node:10-alpine as builder
MAINTAINER joseantonio@gogroup.es
# BUILD ARGS
ARG ENVIROMENT
# Installing GIT & Bash
RUN apk add --no-cache git
## Storing node modules on a separate layer will prevent unnecessary npm installs at each build
COPY package.json package-lock.json ./
RUN npm ci
RUN mkdir /pancho-ui
RUN mv ./node_modules ./pancho-ui
WORKDIR /pancho-ui
COPY . .
## Build the angular app in production mode and store the artifacts in dist folder
RUN npm run ng build --output-path=dist --configuration=$ENVIROMENT --verbose
# STAGE 2: Setup
##############################################################################
# Image
FROM nginx:1.14.1-alpine
MAINTAINER joseantonio@gogroup.es
## Copy our default nginx config
COPY nginx/default.conf /etc/nginx/conf.d/
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## From ‘builder’ stage copy over the artifacts in dist folder to default nginx public folder
COPY --from=builder /pancho-ui/dist /usr/share/nginx/html
RUN mv /usr/share/nginx/html/pancho-ui/* /usr/share/nginx/html/
# Run nginx
CMD ["nginx", "-g", "daemon off;"]
我终于在这个 post 中找到了我的问题的解决方案。
我的 npm run
语法不正确。将参数传递给 npm
命令的正确方法是添加 --
运算符。
就我而言,我需要更改
RUN npm run ng build --output-path=dist --configuration=$ENVIROMENT --verbose
到
RUN npm run ng build -- --output-path=dist --configuration=$ENVIROMENT --verbose