本文介绍了获取browserify需要路径的行为更像requirejs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现移动文件并不断重写文件包含相对于新文件夹的路径时会很痛苦。

I'm finding that it's a pain when moving files around and constantly having to rewrite the file include paths to be relative to their new folder.

我想要在我的browserify代码中避免这种情况:

I want to avoid this in my browserify code:

var View = require('../../../../base/view');

并根据requirejs做更多事情,知道我的基本路径是 js

And do something more in line with requirejs where it knows my base path is js:

var View = require('base/view');


推荐答案

您应该使用路径选项。它没有记录在browserify中,而是在中使用(在引擎盖下使用) :

You should use the paths option. It is not documented in browserify but in node-browser-resolve (used under the hood):

这篇关于获取browserify需要路径的行为更像requirejs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-06 22:48