问题
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