我是第一次尝试使用 Grunt。我认为我正确地遵循了安装和使用 Grunt 插件(grunt-text-replace)的说明。 (例如,请参阅 Grunt's page 和 the plugin's 。)但是我无法成功运行任何内容 - 相反,我不断收到相同的错误。我一直在根据 Grunt 和插件的说明检查我的代码,但我看不出我做错了什么。
这是我的 package.json 文件:
{
"name": "brink-prototype",
"version": "0.0.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-text-replace": "~0.3.2"
}
}
这是我的 Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
replace: {
src: ['components/bootstrap/less/navbar.less'],
dest: 'build/',
replacements: [{
from: /\.box-shadow.*$/g,
to: ''
}]
}
});
grunt.loadNpmTasks('grunt-text-replace');
grunt.registerTask('default', ['replace']);
};
当我在命令行中运行“grunt”时,出现以下错误:
Running "replace:src" (replace) task
Warning: No source files found Use --force to continue.
Aborted due to warnings.
我还使用另一个插件(grunt-regex-replace)尝试了这个过程,并得到了完全相同的错误消息。
我哪里出错了?
更新:
以下是文件结构的相关部分:
- 项目/
- Gruntfile.js
- package.json
- 组件/
- Bootstrap /
- 少/
- 导航栏.less
- 少/
- Bootstrap /
- Node 模块/
- Grunt/
- grunt-text-replace/
我一直在尝试从 Gruntfile.js 所在的 project/目录运行命令。
也许我的src
中的路径应该相对于其他路径?我不知道。
最佳答案
grunt-text-replace 插件要求您指定一个子任务。
replace: {
aSubtaskName: {
src: ['components/bootstrap/less/navbar.less'],
dest: 'build/',
replacements: [{
from: /\.box-shadow.*$/g,
to: ''
}]
}
}
关于node.js - 咕噜警告 : No source files found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16161145/