javascript - Is it possible to use relative paths for directive templateUrls in AngularJS when bundling with Browserify? -
i'm working on web application using angularjs, browserify bundle js files single bundle use in page. structure this:
app |-index.html |-index.js |-bundle.js |-components |-module1 |-index.js |-module1.directive.js |-module1.html because bundled javascript file ends in app folder, directives end looking this:
module.exports = angular.module('module1.directive', []) .directive('moduledirective', function() { return { restrict: 'e', templateurl: './components/module1/module1.html' ); }); this works enough in general, path potentially rather long if project gets complex enough after more developers involved , it's harder move directives around when they're defined way (changing templateurl path step that's relatively easy forget).
what i'd know is, there way me use relative path in templateurl browserify able resolve correctly when bundling files?
edit: if helps, make work if find way original file path script that's being bundled inside module itself, don't know if browserify supports that.
could pathmodify plugin solution problem? more info can found on github (https://github.com/jmm/pathmodify)
var pathmodify = require('pathmodify'); browserify() .plugin(pathmodify(), {mods: [ // make code `require('app/something')` act // `require('/somedir/src/something')` pathmodify.mod.dir('app', '/somedir/src') ]})
Comments
Post a Comment