嗨,我正在尝试使用angular-cli与webpack(+生产力)来构建我的angular2应用程序但是我在尝试延迟加载模块时遇到问题,这些模块正在使用版本beta.10 ...
项目结构:
的package.json
{
"name": "my-app",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.0-rc.7",
"@angular/compiler": "2.0.0-rc.7",
"@angular/core": "2.0.0-rc.7",
"@angular/forms": "^2.0.0-rc.7",
"@angular/http": "2.0.0-rc.7",
"@angular/platform-browser": "2.0.0-rc.7",
"@angular/platform-browser-dynamic": "2.0.0-rc.7",
"@angular/router": "3.0.0-rc.2",
"angular2-cookie": "1.2.3",
"core-js": "2.4.0",
"material-design-icons": "2.2.3",
"material-design-lite": "1.2.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "0.6.21"
},
"devDependencies": {
"@types/jasmine": "2.2.30",
"@types/protractor": "1.5.16",
"angular-cli": "^1.0.0-beta.11-webpack.9-4",
"codelyzer": "0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": …Run Code Online (Sandbox Code Playgroud) angular-cli使用es6模块作为TypeScript的输出格式:在tsconfig.json中:
{
"compilerOptions": {
"modules": "es6",
"target": "es5",
...
Run Code Online (Sandbox Code Playgroud)
以后如何通过webpack处理它以使其在es5中运行?
如果我理解正确,许多项目使用babel来使es6模块工作,但我没有在angular-cli中找到任何关于babel的引用.
我试图从一开始就设置一个webpack项目,因为事实证明angular-cli使用的webpack配置对我们的项目来说不够好/不够灵活.
当我尝试使用es6模块时,我最终在我的"捆绑"js文件中使用了未经处理的"import"语句,所以很明显我做错了.
我angular-cli.json有以下几点:
...
"scripts": [
...
"../node_modules/jquery-ui/ui/widget.js",
"../node_modules/jquery-ui/ui/widgets/datepicker.js",
"../node_modules/jquery-ui-timepicker-addon/dist/jquery-ui-timepicker-addon.js",
...
],
...
Run Code Online (Sandbox Code Playgroud)
在https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/dist/jquery-ui-timepicker-addon.js#L15我得到了Uncaught TypeError: Cannot read property 'timepicker' of undefined.我发现这是因为webpack按以下顺序加载脚本:
jquery-ui-timepicker-addon.js
widget.js
datepicker.js
widget.js以前需要加载jquery-ui-timepicker-addon.js.为什么webpack的加载顺序与配置的顺序不同,如何确定文件的加载顺序?
我正在使用Angular 2 angular-cli.对于客户A,CSS文件style.A.css是相关的,对于客户B来说style.B.css.是否可以apps[0].styles根据活动环境定义css文件?如果没有,任何优雅的解决方案?
CSS的范围是整个应用程序,就像一个完全不同的外观.因此组件范围是不够的.
我遇到了使用anglular-cli ng-cli生成组件的问题,但没有将全新创建的组件添加到app模块:
$ ng g component Try
installing component
create src\app\try\try.component.css
create src\app\try\try.component.html
create src\app\try\try.component.spec.ts
create src\app\try\try.component.ts
update src\app\app.module.ts
No app module found. Please add your new class to your component.
Run Code Online (Sandbox Code Playgroud)
我没有移动任何文件.项目结构是默认的.的src\app\app.module.ts存在,并且具有以下内容:
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {RouterModule} from '@angular/router';
import {AppComponent} from './app.component';
import {ROUTES} from "./app.routes";
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot(ROUTES)
],
declarations: [
AppComponent
],
providers: [],
bootstrap: [AppComponent]
})
export …Run Code Online (Sandbox Code Playgroud) 通常包括分析是关于使用属性Id和网页浏览操作粘贴其在html正文中的跟踪代码.我在Angular2中
跟踪Google Analytics网页视图中的答案,并且在执行ng serve此操作时正确地包含了脚本,但是在生成生产时,它不包含在索引中:
ng build --progress false --aot true -prod -e prod
Run Code Online (Sandbox Code Playgroud)
使用Angular2 Cli包含Google Analytics或其他跟踪解决方案的最佳做法是什么?
提前致谢
我想压缩构建angular项目时创建的包文件.我ng build --environment=${environment}用来构建当前的应用程序和版本"@angular/compiler-cli": "^4.0.0"不生成.gz文件到dist文件夹.生成.gz包文件的最简单方法是什么(最好不要触摸webpack.config.js文件)?PS:我知道.gz有时创建文件的选项会被angular/cli团队删除.但我绝望地需要它,因为我的捆绑文件非常庞大.
通常我运行我的项目并使用WebPack构建我的SASS文件,我有规则生成一个CSS文件,url-loader将所有url(...)sass文件转换为dataURI.
所以background: url('my-file.svg')会转换为background url('data:image/svg+xml;base64,SoMeGiBbeRiShHeRe')
我想知道是否有办法用ng编译器实现这一目标?我对此进行了一些研究,并且使用它的方法是使用ng eject但该选项不再可用.
我正在将Angular 7应用程序配置为生产环境,并尝试在不同目录中组织文件。
angular.json
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/samsara-ui",
"index": "src/index.html",
"main": "src/js/main.ts",
"polyfills": "src/js/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css",
"src/samsara-theme.scss"
],
"scripts": []
},
Run Code Online (Sandbox Code Playgroud)
目前,我的目录如下所示:
??? dist
| ??? <appname>
| | ??? assets
| | | ??? icons
| | | ??? images
| | | index.html
| | | *.js (bundled files: runtime.js, polyfills.js, vendor.js, main.js)
| | | *.map
| | | style.css
| | | *.woff, …Run Code Online (Sandbox Code Playgroud) 在angular-cli的版本8中,构建完成了2倍。ES5中的一项,ES2015中的一项。
是否可以仅在es2015上构建?
将目标更改为es5只能在es5中完成。.但是我还没有找到仅在es2015中实现的方法。
angular ×10
angular-cli ×10
angular7 ×2
webpack ×2
compression ×1
css ×1
gzip ×1
html ×1
lazy-loading ×1