簡體   English   中英

Symfony和RequireJS-如何提供靜態html文件?

[英]Symfony and RequireJS - How to serve static html files?

RequireJS文本插件( https://github.com/requirejs/text )需要擴展名為.html文件。 似乎.html要求無法更改。

我的html文件位於我的Symfony項目的web文件夾中。

使用默認配置, 不可能用Symfony服務任何靜態html文件。

RequireJS正在對模板進行GET請求,但未返回html內容。

有任何已知的解決方法嗎?

最后,我將后端(Symfony)與前端完全分開。

現在,我僅渲染symfony base.html.twig(所有頁面上使用的主要樹枝模板)來導入我的requirejs文件,其中包含網站的所有模板。

模板以純HTML格式開發,然后通過使用Gulp轉換為.txt。 它們都捆綁在requirejs的.js文件中。

gulp.task('devTemplates', ['cleanDevTemplates'], function () {
    gulp.src(srcPaths.devTemplates) // The folder which contains the templates

        .pipe(minifyHtml())
        .pipe(rename({suffix: '', extname: '.txt'}))
        .pipe(gulp.dest(destPaths.devTemplates))

        .pipe(notify({ message: 'devTemplates task complete' }));

});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM