使用Sails.js配置Bower 0.10

时间:2014-09-28 11:14:39

标签: node.js sails.js bower

我安装了grunt-bower模块并跟进了以下链接:

https://stackoverflow.com/a/22456574/194345

但仍无法访问资产文件夹中的js或css文件。

我用bower安装了jquery,它位于" assets \ lib \ jquery \ dist \ jquery.js"但是在浏览器中,尝试使用以下URL来访问它:

http://localhost:1337/js/jquery.js

http://localhost:1337/lib/js/jquery.js

http://localhost:1337/lib/jquery/dist/jquery.js

它始终显示未找到。

正确的道路是什么?

1 个答案:

答案 0 :(得分:4)

我认为您可能没有从您发布的链接中完全实现解决方案,特别是有关配置grunt-bower任务的部分。我编辑了其他优秀的答案,但更清楚 - 你需要将配置包装在一个函数中并保存为 tasks / config / bower.js

module.exports = function(grunt) {
  grunt.config.set('bower', {
    dev: {
        dest: '.tmp/public',
        js_dest: '.tmp/public/js',
        css_dest: '.tmp/public/styles'
    }
  });

  grunt.loadNpmTasks('grunt-bower');

};

然后,下次举起Sails时, jquery.js 将被复制到 .tmp / public / js ,因此可以http://localhost:1337/js/jquery.js使用。< / p>