fex-team / fis3-hook-relative

让 fis3 产出能够支持相对路径。
BSD 2-Clause "Simplified" License
30 stars 8 forks source link

feat: 增加onFetchRelativeFile,暂时解决插件中inline产生相对路径的问题 #20

Closed woshi82 closed 6 years ago

woshi82 commented 7 years ago

add fis.on('plugin:relative:fetchContent', onFetchRelativeFile);

       // 在自定义的插件中
         ……
         file.cache.addDeps(depFileRealPath);

            content = fis.compile.partial(content, temFile, {
               ext: 'html'
            });

            // 触发相对路径调整
            var relativeToFile = relativeTo ? fis.project.lookup(relativeTo).file : file;
            temFile.relativeBody = content;
            var message = {
                file: temFile,
                relativeTo: relativeToFile
            };
            fis.emit('plugin:relative:fetchContent',message)
            message.content && (content =  message.content);
         ……