angular2

angualr-cli.json配置css无效详解

2017-08-22  本文已影响0人  c5bc23873748

.angualr.json

{

"$schema":"./node_modules/@angular/cli/lib/config/schema.json",

"project": {

"name":"ng2"

},

"apps": [

{

"root":"src",

"outDir":"dist",

"assets": [

"assets",

"favicon.ico"

],

"index":"index.html",

"main":"main.ts",

"polyfills":"polyfills.ts",

"test":"test.ts",

"tsconfig":"tsconfig.app.json",

"testTsconfig":"tsconfig.spec.json",

"prefix":"app",

"styles": [

"../node_modules/bootstrap/dist/css/bootstrap.min.css",

"../node_modules/font-awesome/css/font-awesome.min.css",

"../node_modules/primeng/resources/themes/omega/theme.css",

"../node_modules/primeng/resources/primeng.min.css",

"styles.css"

],

"scripts": [

"../node_modules/jquery/dist/jquery.min.js",

"../node_modules/echarts/dist/echarts.min.js"

],

"environmentSource":"environments/environment.ts",

"environments": {

"dev":"environments/environment.ts",

"prod":"environments/environment.prod.ts"

}

}

],

"e2e": {

"protractor": {

"config":"./protractor.conf.js"

}

},

"lint": [

{

"project":"src/tsconfig.app.json",

"exclude":"**/node_modules/**"

},

{

"project":"src/tsconfig.spec.json",

"exclude":"**/node_modules/**"

},

{

"project":"e2e/tsconfig.e2e.json",

"exclude":"**/node_modules/**"

}

],

"test": {

"karma": {

"config":"./karma.conf.js"

}

},

"defaults": {

"styleExt":"css",

"component": {}

}

}

1、.angular-cli.json是配置文件,修改需要重新启动服务。

2、使用cnpm创建目录,我遇到这样的情况无法加载css;

使用 ng new myApp,创建好目录,马上要开始初始化node_modules,默认会使用npm创建node_modules

cmd + c,停止创建。

cnpm install 使用cnpm创建node_modules

配置 .angular-cli.json文件,css不起作用,js也不起作用。

最后删除项目,配置npm国内淘宝镜像

1.临时使用

npm--registry https://registry.npm.taobao.org install express

2.持久使用

npm configsetregistryhttps://registry.npm.taobao.org

// 配置后可通过下面方式来验证是否成功

npmconfiggetregistry

然后使用 ng new myApp 直到结束,cd myApp; ng serve 运行项目,修改配置,没问题了。

好像就是angular-cli对cnpm支持不太好,还是使用npm的好。

3、当然你需要安装响应的包才行。

上一篇 下一篇

猜你喜欢

热点阅读