gruntjs - Absolute path using grunt-wiredep for Grunt + Bower -
the grunt-wiedep
task outputs relative paths assets. instead need absolute paths. so, reconfigured replace
block suggested here: https://github.com/stephenplusplus/grunt-wiredep/issues/46
but, after specifying replace
block suggested, following added script reference. can see, wrong.
<script src="/../../../public/vendors/jquery/dist/jquery.js"></script> <script src="/../../../public/vendors/angular/angular.js"></script> <script src="/../../../public/vendors/angular-resource/angular-resource.js"></script> <script src="/../../../public/vendors/angular-route/angular-route.js"></script>
what want instead:
<script src="/vendors/jquery/dist/jquery.js"></script> <script src="/vendors/angular/angular.js"></script> <script src="/vendors/angular-resource/angular-resource.js"></script> <script src="/vendors/angular-route/angular-route.js"></script>
so, tried replace block. notice regex
:
replace: { js: '<script src="/{{filepath}}"></script>'.replace(/\.\.\/public/gi, ''), css: '<link rel="stylesheet" href="/{{filepath}}" />'.replace(/\.\.\/public/gi, '') }
but appears {{filepath}}
being replaced @ later time , hence regex
not yield expected results.
what ideal way handle such situation?
in gruntfile.js configuration wiredep add following: ignorepath: '/../../../public'
this remove part start of path created wiredep.
for example this, plus whatever adjustments config:
wiredep: { target: { src: [ '/views/**/*.html', ], ignorepath: '/../../../public', dependencies: true, devdependencies: false, } },
Comments
Post a Comment