1

Grunt を初めて使用しようとしています。Grunt をプラグイン (grunt-text-replace) と共にインストールして使用するための指示に正しく従っていると思います。(たとえば、Grunt のページプラグインの. 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
    • パッケージ.json
    • コンポーネント/
      • ブートストラップ/
        • 以下/
          • navbar.less
    • node_modules/
      • うなり声/
      • grunt-text-replace/

Gruntfile.js がある project/ ディレクトリからコマンドを実行しようとしています。

多分私のパスはsrc何か他のものに相対的であるべきですか?知らない。

4

1 に答える 1

1

grunt-text-replace プラグインでは、サブタスクを指定する必要があります。

replace: {
  aSubtaskName: {
    src: ['components/bootstrap/less/navbar.less'],
    dest: 'build/',
    replacements: [{
      from: /\.box-shadow.*$/g,
      to: ''
    }]
  }
}
于 2013-04-23T14:51:50.430 に答える