How would one write a resolve.alias function for gulp?

戏子无情 提交于 2019-12-25 08:48:09

问题


I'm using Gulp and Tape to run my test suite instead of Webpack and Tape. The reason is for speed and simplicity. Gulp functional task approach instead of testing while bundling.

Now, in order for it to work I need to resolve a file path for an import.

In webpack I would use:

resolve: {
   alias: {
      'machingWord' : __dirname
   }
}

So something like this: https://www.npmjs.com/package/gulp-resolve, but not as manual. Want the task to be able to resolve import '...' as it tests it.

Is there a way for me to write a custom gulp.task to take in the file and be able to do this functionality? i'm not to familiar with manipulating the file itself in JS to do this.


回答1:


I found the answer is this plugin: https://www.npmjs.com/package/babel-plugin-module-resolver

It's a little buggy, but it does the trick. Follow the instructions and it will do that job.



来源:https://stackoverflow.com/questions/45265583/how-would-one-write-a-resolve-alias-function-for-gulp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!