Gruntjs Grunt usemin与模板

Gruntjs Grunt usemin与模板,gruntjs,yeoman,Gruntjs,Yeoman,给定以下目录结构: – Gruntfile.js – app |– index.php |– js |– css |– templates |– template.php – dist 如何配置grunt usemin来更新模板文件中相对于使用模板的index.php的样式和脚本的引用 当前任务如下所示: useminPrepare: { html: '<%= yeoman.app %>/templates/template

给定以下目录结构:

– 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:js(app) js/main.js -->
    <script src="js/script1.js"></script>
    <script src="js/script2.js"></script>
<!-- endbuild -->
useminPrepare:{
html:'/templates/template.php',
选项:{
目标:“”
}
},
usemin:{
html:['/{,*/}*.php'],,
css:['/css/*.css'],
选项:{
目录:['']
}
}
模板内部的块如下所示:

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:js(app) 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 -->

... HTML标记,脚本/链接标记列表。
构建块现在如下所示:

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: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 %>']
    }
}
usemin:{
html:'/templates/template.php',
css:['/css/*.css'],
选项:{
目录:['']
}
}

遗憾的是,它与template.php中的实际php代码不兼容。