javascript - grunt bower-install 到 php 文件中

标签 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

最佳答案

就像@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}}'
    }
  }
};

问候

关于javascript - grunt bower-install 到 php 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20914130/

相关文章:

javascript - 我可以用什么来通过这样的线连接两个 div?

debugging - 如何从调试器恢复而不中断 Protractor 中的整个测试?

javascript - Gruntjs 任务问题

gruntjs - Grunt sass 没有安装 ruby​​ 和 sass 吗?

linux - Bower:未找到命令

javascript - HTML 切换菜单消失

javascript - 主干项目 View 需要将 HTML 放入选项卡中

eclipse - Eclipse 中未定义的 CSS/JavaScript/Image 文件

javascript - 你如何运行多个 grunt scripts.postinstall?

javascript - 将 Promise 与事件发射器一起使用