grunt-usemin
我的插件有问题。
基本上,我想将所有静态内容放在orstatic/
下的目录中(取决于应用程序是否构建)。app
dist
现在,这是我的 grunt 配置
useminPrepare: {
html: ['<%= yeoman.app %>/app.html', '<%= yeoman.app %>/login.html'],
options: {
dest: '<%= yeoman.dist %>/static'
}
},
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/static/styles/**/*.css'],
options: {
dirs: ['dist/static/']
}
}
第一部分可以看输出
Found a block:
<!-- build:css(.tmp) login/styles/main.css -->
<link rel="stylesheet" href="styles/bootstrap.css">
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
Updating config with the following assets:
- .tmp/styles/bootstrap.css
- .tmp/styles/main.css
Found a block:
<!-- build:js({app/static}) login/scripts/libs.js -->
<script src="bower_components/angular/angular.js"></script>
<!-- endbuild -->
Updating config with the following assets:
- {app/static}/bower_components/angular/angular.js
Found a block:
<!-- build:js({.tmp,app/static}) login/scripts/scripts.js -->
<script src="scripts/loginApp.js"></script>
<script src="scripts/controllers/login.js"></script>
<!-- endbuild -->
Updating config with the following assets:
- {.tmp,app/static}/scripts/loginApp.js
- {.tmp,app/static}/scripts/controllers/login.js
Configuration is now:
cssmin:
{ 'dist/static/login/styles/main.css': 'dist/static/login/styles/main.css' }
concat:
{ 'dist/static/login/styles/main.css':
[ '.tmp/styles/bootstrap.css',
'.tmp/styles/main.css' ],
'dist/static/login/scripts/libs.js': [ '{app/static}/bower_components/angular/angular.js' ],
'dist/static/login/scripts/scripts.js':
[ '{.tmp,app/static}/scripts/loginApp.js',
'{.tmp,app/static}/scripts/controllers/login.js' ] }
uglify:
{ 'dist/static/login/scripts/libs.js': 'dist/static/login/scripts/libs.js',
'dist/static/login/scripts/scripts.js': 'dist/static/login/scripts/scripts.js' }
requirejs:
{}
但问题在于将普通文件与其 revved 版本交换,例如,这是使用之前的 html:
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Login</title>
<meta name="viewport" content="width=device-width">
<!-- build:css(.tmp) login/styles/main.css -->
<link rel="stylesheet" href="styles/bootstrap.css">
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
</head>
<body ng-app="jsLinkedinConnectorLoginApp">
<div class="container" ng-view=""></div>
<!-- build:js({app/static}) login/scripts/libs.js -->
<script src="bower_components/angular/angular.js"></script>
<!-- endbuild -->
<!-- build:js({.tmp,app/static}) login/scripts/scripts.js -->
<script src="scripts/loginApp.js"></script>
<script src="scripts/controllers/login.js"></script>
<!-- endbuild -->
</body>
</html>
之后:
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Login</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="login/styles/main.css">
</head>
<body ng-app="jsLinkedinConnectorLoginApp">
<div class="container" ng-view=""></div>
<script src="login/scripts/libs.js"></script>
<script src="login/scripts/scripts.js"></script>
</body>
</html>
所以这几乎是正确的,似乎 grunt 没有在dist/static
目录中获取 revved 文件。
现在,当我将例如dist/static/login
目录向上移动时,dist/login
更改dirs
为dist
一切正常,因此给子目录dist
似乎会导致问题。