在Meanjs中,添加了新的库.Json不会自动添加到配置文件中

In Meanjs, adding new lib in bower.json not automatically added to the config file

本文关键字:添加 Json 配置文件 Meanjs      更新时间:2023-09-26

我正在学习Meanjs。我需要为我的项目添加fontaawesome。所以我在wer里加了一个项。Json格式如下:

"dependencies": {
    "bootstrap": "~3",
    "angular": "~1.2",
    "angular-resource": "~1.2",
    "angular-mocks": "~1.2",
    "angular-cookies": "~1.2",
    "angular-animate": "~1.2",
    "angular-touch": "~1.2",
    "angular-sanitize": "~1.2",
    "angular-bootstrap": "~0.11.0",
    "angular-ui-utils": "~0.1.1",
    "angular-ui-router": "~0.2.10",
    "fontawesome": "~4.1.0"
}

并运行' wer install'。软件包下载成功,但fontawesome没有自动链接到我的页面。我应该手动链接这些库吗?

请帮。

您缺少的步骤是在config/env/*.js文件中添加条目。有一个图书馆部分,在那里你可以看到其他图书馆。config/env文件决定了添加到head标签中的链接。

我不知道如何自动添加这些条目

For:
"meanjs-version": "0.4.2"

将库的路径添加到:
/config/assets/*.js

例子:
/config/assets/default.js

module.exports = {
  client: {
    lib: {
      css: [
        'public/lib/bootstrap/dist/css/bootstrap.css',
        'public/lib/bootstrap/dist/css/bootstrap-theme.css',
        'public/lib/angular-typewrite/dist/angular-typewrite.css'
      ],
      js: [
        'public/lib/angular/angular.js',
        'public/lib/angular-resource/angular-resource.js',
        'public/lib/angular-typewrite/dist/angular-typewrite.js'
      ]
    }
   }
}
}

为了自动更新依赖项,我过去使用过wiredp。

npm install --save-dev grunt-wiredep

在你的Gruntfile.js中,你会有一个像这样的块:

grunt.initConfig({
 //bunch of tasks in here
 clean: {...},
 jshint:{...},
 //add the following lines
  wiredep: {
    src: ['<%= yeoman.app %>/index.html', 'you can add', 'other search paths', 'here'],
    block: /(([ 't]*)'/'/'s*bower:*('S*))('n|'r|.)*?('/'/'s*endbower)/gi,  
    replace: {
      js: '{{filePath}}',
     }
    }
  });

一旦将其添加为任务,将该任务添加到任务列表

grunt.registerTask('testOrWhateverYoursIsCalled', [
  //your other tasks here
  'wiredep'
 ]);

然后在你的。config文件或任何你有大js文件列表的地方添加这个:

 //bower:js
 //this will get swapped out for your list of bower components
 //endbower

路径可能很奇怪,但我认为您可以使用cwd来更改路径。不知道如何做到这一点,只是玩了wiredp来取代东西,它工作了!!

刚刚回答了我关于堆栈的第一个问题,终于!!

也许你应该加上

<link rel="stylesheet" href="bower_components/fontawesome/css/font-awesome.min.css">

到你的index.html