public function build()
    {
        $file = rtrim($this->cacheDir, '/').'/'.$this->getFilename();
        $mapFile = $file.'.map';

        $cache = new PuliResourceCollectionCache($file, $this->isDebug());

        $resources = $this->resourceFinder->findByType($this->getType());

        if (!$cache->isFresh($resources)) {
            $resolvedResources = $this->resourceResolver->resolve($resources);
            $mappedContent = $this->contentBuilder->build(
                $this->getFilename(),
                $resolvedResources,
                array($this, 'sanitizePath'),
                array($this, 'prefixContent')
            );

            $cache->write($mappedContent->getContent());
            file_put_contents($mapFile, $mappedContent->getMap());

            if (!$this->debug) {
                $this->compressor->compressFile($file);
            }
        }

        return new MappedAsset($file, $mapFile);
    }