spmjs / grunt-cmd-transport

Transport everything into common module.
MIT License
70 stars 32 forks source link

别名配置,支持替换require路径中的一个字段么? #92

Open xiaoshuimao opened 9 years ago

xiaoshuimao commented 9 years ago
var $ = require('$');

var Handlebars = require('cmd/handlebars/2.0.0/handlebars');

a.js

"options": {
    "alias": {
      "$": "lib/jquery/1.11.1/jquery",
      "cmd": "lib/cmd-plugins/"
    }
  }

packpage.json

请问,我这边 require('cmd/handlebars/2.0.0/handlebars'); 这里的cmd能被别名替换么?或者有什么像seajs一样有path的配置项?

popomore commented 9 years ago

没有,为何不直接 require('handlebars')

xiaoshuimao commented 9 years ago
seajs.config({
 paths: {
   'cmd': 'lib/cmd-plugins'
 }

seajs.config

var $ = require('$');

var Handlebars = require('cmd/handlebars/2.0.0/handlebars');

a.js

是这个情况,我可能seajs那边会有这个path配置,正常use这个a.js没问题。(有类似很多的js使用了这个path变量) 然后我想通过这个transports插件来批量添加id和依赖。