- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
当 javascript 文件 src 路径以“/”开头时,我在使用 Gruntfile.js 时遇到问题。
我关注这个用例 http://briantford.com/blog/angular-yeoman.html
默认情况下,JS文件包含为
<!-- build:js scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<!-- endbuild -->
$ ls dist/scripts/
ab541b7e.app.js afa864c8.scripts.js controllers vendor
$ cat dist/scripts/afa864c8.scripts.js
"use strict";var ...
....
App Engine 应用程序配置 require使用“/”作为前缀。
<!-- build:js scripts/scripts.js -->
<script src="/scripts/app.js"></script>
<script src="/scripts/controllers/main.js"></script>
<!-- endbuild -->
Build results in the concatenated file,
$ ls dist/scripts/
9eecb7db.scripts.js ab541b7e.app.js controllers vendor
$ cat dist/scripts/9eecb7db.scripts.js
但是,连接后的脚本文件是空的。
完整的 Gruntfile 如下,未修改。
module.exports = function( grunt ) {
'use strict';
//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.initConfig({
// Project configuration
// ---------------------
// specify an alternate install location for Bower
bower: {
dir: 'app/components'
},
// Coffee to JS compilation
coffee: {
compile: {
files: {
'app/scripts/*.js': 'app/scripts/**/*.coffee',
'test/spec/*.js': 'test/spec/**/*.coffee'
}
}
},
// compile .scss/.sass to .css using Compass
compass: {
dist: {
// http://compass-style.org/help/tutorials/configuration-reference/#configuration-properties
options: {
css_dir: 'temp/styles',
sass_dir: 'app/styles',
images_dir: 'app/images',
javascripts_dir: 'temp/scripts',
force: true
}
}
},
// generate application cache manifest
manifest:{
dest: ''
},
// default watch configuration
watch: {
coffee: {
files: 'app/scripts/**/*.coffee',
tasks: 'coffee reload'
},
compass: {
files: [
'app/styles/**/*.{scss,sass}'
],
tasks: 'compass reload'
},
reload: {
files: [
'app/*.html',
'app/styles/**/*.css',
'app/scripts/**/*.js',
'app/views/**/*.html',
'app/images/**/*'
],
tasks: 'reload'
}
},
// default lint configuration, change this to match your setup:
// https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#lint-built-in-task
lint: {
files: [
'Gruntfile.js',
'app/scripts/**/*.js',
'spec/**/*.js'
]
},
// specifying JSHint options and globals
// https://github.com/cowboy/grunt/blob/master/docs/task_lint.md#specifying-jshint-options-and-globals
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
angular: true
}
},
// Build configuration
// -------------------
// the staging directory used during the process
staging: 'temp',
// final build output
output: 'dist',
mkdirs: {
staging: 'app/'
},
// Below, all paths are relative to the staging directory, which is a copy
// of the app/ directory. Any .gitignore, .ignore and .buildignore file
// that might appear in the app/ tree are used to ignore these values
// during the copy process.
// concat css/**/*.css files, inline @import, output a single minified css
css: {
'styles/main.css': ['styles/**/*.css']
},
// renames JS/CSS to prepend a hash of their contents for easier
// versioning
rev: {
js: 'scripts/**/*.js',
css: 'styles/**/*.css',
img: 'images/**'
},
// usemin handler should point to the file containing
// the usemin blocks to be parsed
'usemin-handler': {
html: 'index.html'
},
// update references in HTML/CSS to revved files
usemin: {
html: ['**/*.html'],
css: ['**/*.css']
},
// HTML minification
html: {
files: ['**/*.html']
},
// Optimizes JPGs and PNGs (with jpegtran & optipng)
img: {
dist: '<config:rev.img>'
},
// rjs configuration. You don't necessarily need to specify the typical
// `path` configuration, the rjs task will parse these values from your
// main module, using http://requirejs.org/docs/optimization.html#mainConfigFile
//
// name / out / mainConfig file should be used. You can let it blank if
// you're using usemin-handler to parse rjs config from markup (default
// setup)
rjs: {
// no minification, is done by the min task
optimize: 'none',
baseUrl: './scripts',
wrap: true
}
});
// Alias the `test` task to run `testacular` instead
grunt.registerTask('test', 'run the testacular test driver', function () {
var done = this.async();
require('child_process').exec('testacular start --single-run', function (err, stdout) {
grunt.log.write(stdout);
done(err);
});
});
};
做一些研究导致下面的 repo,yeoman 使用它来替换标记。 https://github.com/yeoman/grunt-usemin
还需要搞清楚,前面加“/”有什么问题
最佳答案
实际上,您的用例应该得到支持。但是,请注意:
关于javascript - Grunt/Yeoman 用绝对路径连接 javascript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14076927/
我正在尝试全新安装 Yeoman,但在我尝试使用以下命令将其删除后,Yo 命令仍然存在: sudo npm remove -g yeoman npm remove -g yeoman sudo npm
当 yeoman 以嵌入形式运行时,我无法运行子生成器。 integrating yeoman in other tools 的文档提供这个例子: var yeoman = require('yeom
使用最新的 yeoman 更新 1.0,我们是否能够更改创建目录结构的方式?例如...如果我想在根目录而不是“/app”文件夹中创建我的文件,这可能吗?另外,如果我们想将我们的 Assets 文件夹命
我喜欢 Yeoman 的功能,例如 Package Manager (Bower)、Livereload 集成、Compass 等。 因此,我想用它来处理我的公共(public)网站。但是,我不想使用
我是创建 Yeoman Generator 的新手。我使用了 generator-generator 来让我开始,我经历了创建它、测试和把它全部搞定的过程。 在创建 yo 生成器的 tuts 中,他们
为什么不推荐 Yeoman 在他们的网站上写网站时建立网站 http://yeoman.io/road.html Clearing up misconceptions […] - Not recomm
尝试执行yo angular时出现以下错误: 在脚手架中,还有其他错误消息。 我做了: npm install -g yonpm install -g generator-angularyo angu
我试过console.log('message') ,但它以黑色返回消息。 有没有办法在生成器中记录彩色消息? 最佳答案 对于查看此问题的新用户 console.log();根据 Documentat
我正在为一个相当典型的节点应用程序构建一个自耕农生成器: / |--package.json |--.gitignore |--.travis.yml |--README.md |--app/
几个月前,我使用生成器角度来搭建一个项目,整个生态系统(karma、Node 版本、grunt 包)已经取得了相当大的进展。我在运行测试、构建东西等方面不断遇到问题。 我知道我可以使用 nvm 降级我
我不小心安装了一个我不想要的生成器。 我找不到任何方法来删除它。 我应该怎么做才能实现这个目标? 最佳答案 生成器只是普通的 npm 模块,因此您可以使用以下命令删除它 npm uninstall -
我创建了一个 Yeoman 生成器并希望我的团队使用它。 如果我在 Github 上更新我的生成器会发生什么?他们在本地安装了旧版本的生成器。他们是否总是需要重新安装才能获得最新版本? 团队成员不知道
我正在构建一个生成器,最后我需要在应用程序的某个目录中进行npm install,我尝试了以下操作: this.spawnCommandSync('cd', [this.destinationRoot
在使用 Yeoman 搭建脚手架时,我想用模板替换应用程序中的部分内容。一切似乎都很顺利,但我在脚手架期间遇到了此冲突错误。 这个. 模板( '条件文件/html/_signup.email.html
我是一名 javascript 初学者,通过遵循编写第一个生成器教程并阅读其他生成器代码,我已经成功地使用我的第一个生成器实现了这一目标。 我尝试了各种方法来使其正常工作,但都失败了,如果有人能指出我
我正在为 yeoman 使用角度生成器,目前默认行为是我这样做的时候 yo angular:controller testController 我创建了 2 个文件 create app\script
所以我一直在为我的项目使用 yeoman.io,并且我为我的图像设置了文件夹结构。但是当我构建它时,我的文件的文件名发生了变化。 我什至使用: $ yeoman build:text 因为我只想缩小我
如何通过自耕农生成器创建一个空目录? 我看过 mem-fs-editor ,但据我所知,只有在创建子文件时才会创建目录。我试过在子目录中创建一个文件,然后删除该文件,但这不起作用(我假设因为 mem-
我正在构建一个生成器,其中部分包含来自使用 exec 创建的另一个项目的脚手架.根据用户输入,我需要移动或删除此脚手架的一部分。 现在我正在用节点的 fs.child_process.spawn 做这
我正在跟踪yeoman.io上列出的示例Yeoman工作流程: npm install -g generator-angular generator-karma # install generato
我是一名优秀的程序员,十分优秀!