我不希望angular cli重命名生成的脚本文件ng build --prod,并将其链接放在index.html文件中。我只想一次又一次地使用相同的名称,就像在prod版本的开发版本中一样。
我知道.angular-cli.json文件中包含所有配置,但是我需要放置什么选项来停止重命名产品以进行产品构建。
另一个选择是在webpack内部使用angular cli ,我们可以配置任何方式webpack来处理文件重命名。
我使用Angular-CLI创建了一个应用程序,并且出于调试目的,希望在应用程序中显示有关正在运行的构建的一些信息.例如,git分支或构建时间等.
我可以编写一个操作的脚本,src/environments/environment.ts但我问自己是否有更好的方法.特别是因为该文件是源代码控制的一部分.
在Angular-CLI上切换以覆盖变量的值会很好.让我们说变量environment.build并environment.time设置为dummys in environment.ts.然后ng --env[build]=master --env[time]=201612130742我会用计算值覆盖那些.
但据我所知,这样的东西不存在?
运用
"@angular/cli": "^1.0.0"
Run Code Online (Sandbox Code Playgroud)
@angular/cli 忽略 tsconfig.json
该项目编译很好的编辑/删除 tsconfig.json
这是为什么?
我想了解如何将多个bundle.js文件(例如main.bundle.js,scripts.bundle.js等)(数量为5个)合并到一个bundle.js文件中,并在index.html中创建引用.我正在使用angular-cli,它依次使用webpack.
我能够使用单独的npm模块合并文件,但不使用webpack配置.
我正在编写一个需要ng build在特定目录中运行的自动构建脚本.我的项目有以下结构:
project
? build-script
? project-client
? package.json
Run Code Online (Sandbox Code Playgroud)
ng build正在寻找package.json文件,但它无法在当前位置找到它.有没有办法可以直接ng build到子目录而不做一个cd(因为bash对于更改目录有点不稳定)?基本上,我只需要一种方法来告诉ng build我在我指定的目录中操作.
我已经尝试过,ng build ./project-client/但它给出的错误是"你必须在angular-cli项目中才能使用build命令"
谢谢.
我遵循了角度的官方指南并成功安装了初始服务工作者.接下来我想尝试更新行为并得到一个
TypeError:无法读取未定义的属性"id"
其中id指的是ngsw-worker.js中方法中的client.id
async updateClient(client) {
// Figure out which version the client is on. If it's not on the latest,
// it needs to be moved.
const existing = this.clientVersionMap.get(client.id);
....
}
Run Code Online (Sandbox Code Playgroud)
我做的步骤是
我正在使用angular-cli 1.7.4,包括service-worker在内的所有角度库都在5.2.10上.
编辑1 08.05.2018
在angular-cli上的github上发布了一个问题6 https://github.com/angular/angular/issues/23742
编辑2 08.05.2018
到目前为止我能找到的东西:
ng build --prod不会创建新版本的ngsw-worker.js(在重新加载新的构建时,chrome不会显示"等待激活").当我重新加载或不加之前关闭选项卡时,会出现错误.
当我手动向ngsw-worker.js添加内容(如console.log)时,通常生命周期开始,旧服务工作者正在被"新"服务工作者替换.
当我在激活完成之前重新加载时,会出现相同的错误.否则它有效......
此外,尝试使用angular的故障安全(删除或重命名ngsw-config)删除服务工作程序会导致构建错误.
预计在/ Users/hanche/Desktop/Development/playground/toggl2文件夹中找到一个ngsw-config.json配置文件.在angular.json配置文件中提供一个或禁用Service Worker.
编辑3&'解决方案 '09.05.2018
如果接受2018年5月1日的拉动请求,则该问题应该得到解决.
同时,您可以通过从dist /文件夹中删除ngsw.json而不是ngsw-config.json来自动取消注册serviceworker,如故障安全部分所述.看到我在这里的回复.
此外,它也可能是一个铬虫
当我尝试使用此命令安装angular cli时
npm install -g @angular/cli
我得到了下面提到的错误
npm WARN可选SKIPPING OPTIONAL DEPENDENCY:fsevents@^1.0.0(node_modules\@angular\cli \node_modules\chokidar \node_modules\fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:不支持的fsevents@1.2.4平台:want {"os ":""darwin","arch":"any"}(当前:{"os":"win32","arch":"x64"})npm WARN可选跳过选项依赖:fsevents@^1.1.2(node_modules\@angular\cli \node_modules\watchpack \node_modules\chokidar \node_modules\fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:不支持的fsevents@1.2.4平台:want {"os":"darwin","arch":"任何"}(当前:{"os":"win32","arch":"x64"})npm WARN可选SKIPPING OPTIONAL DEPENDENCY:fsevents@^1.1.2(node_modules\@angular\cli \node_modules\webpack-dev -server \node_modules\chokidar \node_modules\fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:不支持的fsevents@1.2.4平台:want {"os":"darwin","arch":"any"}(当前:{ "os":"win32","arch":"x64"})npm WARN ajv-keywords@3.2.0需要一个同行 jv@^6.0.0但没有安装.npm WARN可选SKIPPING OPTIONAL DEPENDENCY:node-sass@4.9.0(node_modules\@angular\cli \node_modules \node-sass):npm WARN可选SKIPPING OPTIONAL DEPENDENCY:node-sass@4.9.0 postinstall:`node scripts/build .js npm WARN可选SKIPPING OPTIONAL DEPENDENCY:退出状态1
任何想法是什么问题?
我的节点版本是6.9.2,npm版本是3.10.9
如果你想帮我检查一下发生了什么,这里是Github的存储库:https://github.com/sandrocsimas/ngx-material-palette-picker
我正在尝试创建我的第一个角度库.我使用angular cli命令生成代码:
ng new ngx-material-palette-picker-app
ng generate library ngx-material-palette-picker
Run Code Online (Sandbox Code Playgroud)
在NgxMaterialPalettePickerComponent我正在导入json文件的组件中,但构建引发了以下错误:
projects/ngx-material-palette-picker/src/lib/ngx-material-palette-picker.component.ts(2,31): error TS2307: Cannot find module './palettes.json'.
Run Code Online (Sandbox Code Playgroud)
这是我的组成部分:
import {Component, OnInit} from '@angular/core';
import * as palettesJSON from './palettes.json';
@Component({
selector: 'ngx-mpp',
template: `,
styles: []
})
export class NgxMaterialPalettePickerComponent implements OnInit {
constructor() {
}
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个types在根路径中调用的目录,并将以下代码添加到index.d.ts:
declare module '*.json' {
const value: any;
export default value;
}
Run Code Online (Sandbox Code Playgroud)
我还添加了目录types到typeRoots主tsconfig.json.
"typeRoots": [
"node_modules/@types",
"types"
],
Run Code Online (Sandbox Code Playgroud)
该项目在Sublime编辑器中没有显示任何错误,但是当我尝试使用该命令构建项目时,ng build …
通常我运行我的项目并使用WebPack构建我的SASS文件,我有规则生成一个CSS文件,url-loader将所有url(...)sass文件转换为dataURI.
所以background: url('my-file.svg')会转换为background url('data:image/svg+xml;base64,SoMeGiBbeRiShHeRe')
我想知道是否有办法用ng编译器实现这一目标?我对此进行了一些研究,并且使用它的方法是使用ng eject但该选项不再可用.
在此之后,我尝试更新角度CLI ,但现在无法运行我的应用程序。当我尝试运行命令时ng serve,它给了我这个错误:
Could not find the implementation for builder @angular-devkit/build-angular:dev-server
Error: Could not find the implementation for builder @angular-devkit/build-angular:dev-server
at WorkspaceNodeModulesArchitectHost.resolveBuilder (C:\Users\Lupus\Documents\full-stack-projects\financial-app-ui\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:49:19)
at ServeCommand.initialize (C:\Users\Lupus\Documents\full-stack-projects\financial-app-ui\node_modules\@angular\cli\models\architect-command.js:135:55)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Run Code Online (Sandbox Code Playgroud)
我已经尝试了所有可能找到的东西。
npm install --save-dev @angular-devkit/build-angularnpm i --only=dev:
npm install
ng update
npm update
Run Code Online (Sandbox Code Playgroud)
node_modules文件夹和package-lock.json文件,然后再次运行了所有命令。没事。跑步ng v给我这个:
Angular CLI: 8.0.3
Node: 10.15.0
OS: win32 x64
Angular: 8.0.1
... …Run Code Online (Sandbox Code Playgroud) angular-cli ×10
angular ×8
node.js ×2
angular4 ×1
bash ×1
ecmascript-6 ×1
npm ×1
typescript ×1
webpack ×1