簡體   English   中英

grunt bower-install進入php文件

[英]grunt bower-install into the php file

我有以下問題:

我正在嘗試在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}}'
    }
  }
};

問候

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM