私はgruntfileでnodeコマンドを実行しようとしています。私は実行する必要があります:グランツ経由でノードスクリプトを実行するにはどうすればよいですか?
node index.js
他のタスクの前の最初のタスクとして実行する必要があります。私は周りを検索しようとしたが、答えを見つけていない。私はそれが何か単純かもしれないと信じていますが、私はどのように確信がありません。 nmpタスクを読み込む必要がありますか?
"use strict";
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js'
],
options: {
jshintrc: '.jshintrc',
},
},
// Before generating any new files, remove any previously-created files.
clean: {
tests: ['dist/*']
},
// Configuration to be run (and then tested).
mustache_render: {
json_data: {
files: [
{
data: 'jsons/offer.json',
template: 'offers.mustache',
dest: 'dist/offers.html'
},
{
data: 'jsons/profile.json',
template: 'profile.mustache',
dest: 'dist/profile.html'
}
]
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-mustache-render');
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('default', ['clean', 'jshint', 'mustache_render']);
};
私は「クリーン」タスクの前に「ノードindex.js」を実行したい:
これは私のGruntfileがどのように見えるかです。
hmm ...上記のファイルを実行した結果はどうなりますか? –
質問が更新されました。 – Blueboye
この回答を確認してください、私のために働いた! https://stackoverflow.com/a/47304117/5346095 –