javascript - Set custom paths to files in Browserify -
I'm taking a crack on changing my current RequireJS workflow into a browser + to see one, only my frontend Javascript (my backend is Ruby) The only issue I am running is that I do not have a convenient place to confirm that I have named "named path". Suppose that my frontend is structured like this:
app / Model / examplemodel.js view / exampleviews JS Main JS Usage / Backbone-All Js vendor / jquery-2.1.0.js spine-1.1.2.js backbone-mariannet-2.0.1.js underscore-1.6.0.js
In the above example, two things Keep in mind:
- All my generated files are correct in their filename
-
Backbone-all Note in js
file inutil
folder With RequirejS, I can do something like the following:required.config ({path: { "Jquery": "vendor / jquery-2.1 .0", "backbone": "vendor / backbone -1.1.2", "underscore": "vendor / underscore-1.6.0", "backbone-all": "usage / Backbone-all "}});
And instead of fully qualified (or relative) path, be able to require my code only by name. I have not been successful in extracting a way to work properly in this way, on which I want to be on the frontend. The closest I had to do is create a dependency map file that is loaded before my application starts (and is available worldwide), and use it as a key:
window. D = window.dependency = {"Jquery": "/vendor/jquery-2.1.0", "backbone": "/vendor/backbone-1.1.2", "underscore": "/vendor/underscore-1.6.0 "," Backbone-all ":" / use / backbone-all "}; Var $ = Requirement (d.jquery);
Has anyone encountered this problem, or has come in a suitable solution? I came who was similar, but the answer was not received 6 months ago. Maybe things have changed.
In your browser
field, type your package.json
To configure a map similar to the requirement of the path
map of js, see.
"Browser": {"jquery": "./vendor/jquery-1.42.js", "./lib/ops.js": "./browser/optsJS"}
Comments
Post a Comment