grunt bower-install到php文件中

时间:2014-01-03 22:49:04

标签: javascript gruntjs bower

我有以下问题:

我正在尝试在php中添加路由js文件。 在html文件中工作得很好。

为什么不在php文件中工作?

尝试:

grunt bower-install

错误:

Verifying property bower-install.app.src exists in config...OK
Reading bower.json...OK
Parsing bower.json...OK
Warning: Cannot read property 'block' of undefined Use --force to continue.

代码:

bower: {
      dev: {
        dest: './components'
      },
    },
    'bower-install': {
      app: {
        src: ['template.php']
      },
    },
  }

自一周前出现问题,但没有回应。 https://github.com/stephenplusplus/grunt-bower-install/issues/33

1 个答案:

答案 0 :(得分:2)

就像@SimonBoudrias说的那样。您必须转到以下文件路径:

node_modules/grunt-bower-install/node_modules/wiredep/lib/inject-dependencies.js

添加到fileTypesDefaults对象,对象 php

var fileTypesDefault = {
  html: {
    block: /(([\s\t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
    detect: {
      js: /<script.*src=['"](.+)['"]>/gi,
      css: /<link.*href=['"](.+)['"]/gi
    },
    replace: {
      js: '<script src="{{filePath}}"></script>',
      css: '<link rel="stylesheet" href="{{filePath}}" />'
    }
  }, php: {
    block: /(([\s\t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
    detect: {
      js: /<script.*src=['"](.+)['"]>/gi,
      css: /<link.*href=['"](.+)['"]/gi
    },
    replace: {
      js: '<script src="{{filePath}}"></script>',
      css: '<link rel="stylesheet" href="{{filePath}}" />'
    }
  },

  yaml: {
    block: /(([\s\t]*)#\s*bower:*(\S*))(\n|\r|.)*?(#\s*endbower)/gi,
    detect: {
      js: /-\s(.+)/gi,
      css: /-\s(.+)/gi
    },
    replace: {
      js: '- {{filePath}}',
      css: '- {{filePath}}'
    }
  }
};

问候