我正在使用Yeoman来构建一个Angular应用程序。
在JavaScript中,有一部分内容只想在构建(进入dist文件夹)时包含在页面中。
是否有办法告诉grunt任务在开发期间运行'grunt server'时跳过模板的某个部分,并仅在构建时包含它?
在JavaScript中,有一部分内容只想在构建(进入dist文件夹)时包含在页面中。
是否有办法告诉grunt任务在开发期间运行'grunt server'时跳过模板的某个部分,并仅在构建时包含它?
它允许您在HTML中放置某些指令。在您的情况下,remove
指令可能是您要寻找的内容:
<!-- build:remove -->
<p>This will be removed when any process is done</p>
<!-- /build -->
<!-- build:dist:remove -->
<p>But this one only when doing processhtml:dist</p>
<!-- /build -->
当然,您也可以将代码片段反转,仅在服务器模式下删除它。如果将任务配置为在.tmp/
中输出HTML,则connect服务器会自动从那里提供文件。
然后,您可以将processhtml
任务添加到服务器的任务列表中,例如:
grunt.task.run([
'clean:server',
'concurrent:server',
'autoprefixer',
'processhtml:server',
'connect:livereload',
'open',
'watch'
]);
watch: {
html: {
files: ['<%= yeoman.app %>/*.html'],
tasks: ['processhtml:server']
}
}