Grunt usemin with templates
Given the following directory structure:
– Gruntfile.js
– app
|– index.php
|– js
|– css
|– templates
|– template.php
– dist
How can I configure grunt usemin to update the references to styles and scripts in my template file relative to the index.php which uses the template?
currently the tasks look like this:
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 %>']
}
}
And the blocks inside of the template look like this:
<!-- build:js js/main.js -->
<script src="js/script1.js"></script>
<script src="js/script2.js"></script>
<!-- endbuild -->
Okay I found it out: The solution is to use the alternate search path option:
<!-- build:<type>(alternate search path) <path> -->
... HTML Markup, list of script / link tags.
<!-- endbuild -->
The build blocks now look like this:
<!-- build:js(app) js/main.js -->
<script src="js/script1.js"></script>
<script src="js/script2.js"></script>
<!-- endbuild -->
and the usemin task is configured as follows:
usemin: {
html: '<%= yeoman.dist %>/templates/template.php',
css: ['<%= yeoman.dist %>/css/*.css'],
options: {
dirs: ['<%= yeoman.dist %>']
}
}
链接地址: http://www.djcxy.com/p/70480.html
上一篇: 无法使用SSDP接收正确的UDP数据包
下一篇: 咕噜usemin与模板