咕噜usemin与模板

鉴于以下目录结构:

– Gruntfile.js
– app
    |– index.php
    |– js
    |– css
    |– templates
         |– template.php
– dist

如何配置grunt usemin以更新模板文件中相对于使用该模板的index.php中样式和脚本的引用?

目前这些任务看起来像这样:

useminPrepare: {
    html: '<%= yeoman.app %>/templates/template.php',
    options: {
        dest: '<%= yeoman.dist %>'
    }
},
usemin: {
    html: ['<%= yeoman.dist %>/{,*/}*.php'],
    css: ['<%= yeoman.dist %>/css/*.css'],
    options: {
        dirs: ['<%= yeoman.dist %>']
    }
}

模板内部的块如下所示:

<!-- build:js js/main.js -->
    <script src="js/script1.js"></script>
    <script src="js/script2.js"></script>
<!-- endbuild -->

好吧,我发现它:解决方案是使用备用搜索路径选项:

<!-- build:<type>(alternate search path) <path> -->
... HTML Markup, list of script / link tags.
<!-- endbuild -->

构建块现在看起来像这样:

<!-- build:js(app) js/main.js -->
    <script src="js/script1.js"></script>
    <script src="js/script2.js"></script>
<!-- endbuild -->

并且usemin任务配置如下:

usemin: {
    html: '<%= yeoman.dist %>/templates/template.php',
    css: ['<%= yeoman.dist %>/css/*.css'],
    options: {
        dirs: ['<%= yeoman.dist %>']
    }
}
链接地址: http://www.djcxy.com/p/70479.html

上一篇: Grunt usemin with templates

下一篇: streaming live video from android to wowza