-               //Create output dir on demand
-               if (!is_dir($parent = $dir = dirname($this->prefix.$output))) {
-                       //XXX: set as 0777, symfony umask (0022) will reduce rights (0755)
+               //Retrieve asset uri
+               //XXX: this path is the merge of services.assets.path_package.arguments[0] and rapsys_pack.output.(css,img,js)
+               if (($outputUrl = $this->package->getUrl($output)) === false) {
+                       throw new Error(sprintf('Unable to get url for asset: %s', $output), $token->getLine(), $stream->getSourceContext());
+               }
+
+               //Check if we have a bundle path
+               if ($output[0] == '@') {
+                       //Check that we have a / separator between bundle name and path
+                       if (($pos = strpos($output, '/')) === false) {
+                               throw new Error(sprintf('Invalid output path "%s"', $output), $token->getLine(), $stream->getSourceContext());
+                       }
+                       //Resolve bundle prefix
+                       $output = $this->locator->locate(substr($output, 0, $pos)).substr($output, $pos + 1);
+               }
+
+               //Create output dir if not present
+               if (!is_dir($dir = dirname($output))) {