- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用 usemin 任务来执行 concat 和 uglify 任务。但是,我没有从 concat/uglify 任务中获得任何输出。没有看到任何错误或警告。如何获得结果输出 dist/app/myscript.js 脚本?
Gruntfile.js 如下:
module.exports = function(grunt){
var paths = {
app: 'app',
dist: 'dist'
};
grunt.initConfig({
paths: paths,
clean: {
dist: {
src: ['<%= paths.dist %>']
}
},
copy: {
dist: {
files: [
{expand: true, cwd: '.', src: ['**'], dest: '<%= paths.dist %>/'}
]
}
},
useminPrepare: {
html: '<%= paths.dist %>/<%= paths.app %>/index.html'
},
usemin: {
html: '<%= paths.dist %>/<%= paths.app %>/index.html'
}
});
grunt.loadNpmTasks('grunt-usemin');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['clean','copy']);
grunt.registerTask('use', ['useminPrepare','usemin'])
}
<!-- build:js myscript.js -->
<script type="text/javascript" src='router.js'></script>
<script type="text/javascript" src='bootstrap.js'></script>
<!-- endbuild -->
Running "useminPrepare:html" (useminPrepare) task
Going through dist/app/index.html to update the config
Looking for build script HTML comment blocks
Found a block:
<!-- build:js myscript.js -->
<!-- Globals -->
<script type="text/javascript" src='router.js'></script>
<script type="text/javascript" src='bootstrap.js'></script>
<!-- endbuild -->
Updating config with the following assets:
- dist/app/router.js
- dist/app/bootstrap.js
Configuration is now:
cssmin:
{}
concat:
{ 'dist/app/myscript.js':
[ 'dist/app/router.js',
'dist/app/bootstrap.js' ] }
uglify:
{ 'dist/app/myscript.js': 'dist/app/myscript.js' }
requirejs:
{}
Running "usemin:html" (usemin) task
Processing as HTML - dist/app/index.html
Update the HTML to reference our concat/min/revved script files
Update the HTML with the new css filenames
Update the HTML with the new img filenames
Update the HTML with data-main tags
Update the HTML with the data tags
Update the HTML with background imgs, case there is some inline style
Update the HTML with anchors images
Update the HTML with reference in input
Done, without errors.
最佳答案
事实证明问题出在 registerTask() 上。您需要显式添加 concat/uglify。所以它应该是这样的: grunt.registerTask('use', ['useminPrepare','usemin','concat','uglify'])
关于gruntjs - 如何从usemin任务中获取输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16682304/
来自 usemin issues看来 usemin 和 useminPrepare 在最新版本中支持多个目标: 在useminPrepare中支持多个目标: pull#162 pull#206 用户支
我使用的是Grunt task runner,Gruntfile.js"如下: 'use strict'; module.exports = function(grunt){ require('tim
以下是我的 index.html 文件中的示例 usemin 构建配置 对于开发版本,我不想缩小脚本,我希望每个模块都放入自己的 js 文件中。所以运行后的 index.html
我在我的 angularjs 项目中使用 grunt 和 usemin。具体来说,我的问题与 usemin 有关不在 View 子目录中的任何 *.html 文件中加速图像标记。 我的 .html 文
给定以下目录结构: – Gruntfile.js – app |– index.php |– js |– css |– templates |– te
使用 GruntJS ,是否可以用远程路径(或者只是任何路径)替换 HTML 文件中的某些资源?我对使用 usemin 做这件事特别感兴趣。插件。 可能的示例功能: 之前 之后 这个想法与 u
我遵循了以下教程: https://www.youtube.com/watch?v=gIbfDxF69c8 并不断收到“找不到”“usemin”目标。gruntfile.js: http://www.
我有一个带有“webapp-generator”脚手架的 Yeoman 项目,它包含一个带有嵌套 HTML 文件的静态网站,类似于此结构: -root/ index.html -direc
我的 grunt usemin 不适用于我的 javascript,它位于 app/scripts 上,仅适用于 app 文件夹之外的脚本,例如 Bower。我的意思是,usemin 不会丑化我的应用
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 1 年前。 Improve
我正在使用 grunt-usemin插入。我想知道下面该怎么做。 我在 index.html 中有两个 usemin 配置 block 。 ... ... .... ... 第一个 blo
我有一个关于 usemin 的问题,我不确定它是否是一个错误。 我的应用程序结构很简单: - root |- gulpfile.js |- app | |- index.h
我使用 Yeoman 搭建了一个 AngularJS 项目。我使用“rev”任务来帮助确保我的图像、脚本、样式等得到唯一标识。 在我的 AngularJS 应用程序中,我有一个使用 ng-includ
我有一个由 yeoman-generator 支持的 grunt 项目,它是我基于 generator-webapp 构建的。 ,如果有帮助的话可以在 GitHub 上找到 grunt 项目让我们有了
我的 gruntfile 中有以下内容: usemin: { html: ['/**/*.html'], css: ['/styles/**/*.css'], js: ['/s
我正在尝试让 gruntfile 工作以连接/丑化 Laravel 应用程序中的 javascript 文件。我的所有任务都是独立工作的,但无论出于何种原因,我的输入 javascript 文件的路径
我使用 grunt usemin 插件来编译我的 requirejs 文件。在我的 html 页面中,我有以下代码段: 这是我的 grunt 文件: /*global module:false*
我目前正在使用 gulp-usemin插件,但是我正在努力解决一件事:使用包提供的图像! font-awesome bower 包还附带字体: bower_components/fo
我是 grunt 的新手,我开始使用 yeoman generator-angular 并重组我的项目,现在我正试图让 grunt 构建再次发挥作用。 这是我的 grunt build 的输出 我的一
我正在使用 Yeoman Webapp 生成器来构建我的静态网站。 对于我的预加载器,我有以下代码片段(如果重要的话,我正在为 JS 使用 requireJS)。 for(var i = 1; i <
我是一名优秀的程序员,十分优秀!