2017-08-18 13 views
0

これはうなり声と私の最初の日であり、私はそれがこれらのチュートリアル兵卒タスクのほとんどが見つからない

https://css-tricks.com/autoprefixer/

https://24ways.org/2013/grunt-is-not-weird-and-hard/そして、私のGruntfile.jsはこれですを使用して動作するようにしようとしています:

module.exports = function(grunt) { 
// 1. All configuration goes here 
grunt.initConfig({ 
pkg: grunt.file.readJSON('package.json'), 
watch: { 
    scripts: { 
    files: ['scripts/app.js'], 
    tasks: ['uglify'], 
    options: { 
     spawn: false, 
    }//For some reason I had a come here. Don't know if it matters 
    }, 
    css: { 
    files: ['content/app.scss'], 
    tasks: ['sass'], 
    options: { 
     spawn: false, 
    } 
    }, 
    styles: { 
    files: ['content/app.css'], 
    tasks: ['autoprefixer'] 
    } 
}, 
uglify: { 
    build: { 
    src: "scripts/app.js", 
    dest: "scripts/app-final.js" 
    } 
}, 
sass: { 
    dist: { 
    options: { 
     style: 'compressed' 
    }, 
    files: { 
     'content/app.css': 'content/app.scss' 
    } 
    } 
}, 
autoprefixer: { 
    dist: { 
    files: { 
     'content/app-prefixed.css': 'content/app.css' 
    } 
    } 
}, 
imagemin: { 
    dynamic: { 
     files: [{ 
      expand: true, 
      cwd: 'assets/img/', 
      src: ['**/*.{png,jpg,gif}'], 
      dest: 'assets/img/' 
     }] 
    } 
} 
}); 


// 3. Where we tell Grunt we plan to use this plug-in. 
grunt.loadNpmTasks(
'grunt-contrib-uglify', 
'grunt-contrib-sass', 
'grunt-autoprefixer', 
'grunt-contrib-watch', 
'grunt-contrib-imagemin' 
); 

// 4. Where we tell Grunt what to do when we type "grunt" into the terminal. 
grunt.registerTask(
'default', [ 
    'watch', 
    'uglify', 
    'sass', 
    'autoprefixer', 
    'imagemin' 
]); 
}; 

しかし、私はうなり声時計時計をしようとすると、私はこの取得:

grunt uglify物事が奇妙ようにするに
# grunt watch 
Warning: Task "watch" not found. Use --force to continue. 
Aborted due to warnings. 

# grunt uglify 
Running "uglify:build" (uglify) task 
>> Destination scripts/app-final.js not written because src files were empty. 
>> No files created. 
Done, without errors. 

grunt --helpを実行すると、私は本当にuglifyと他の機能の違いを見つけることができません

Available tasks 
    uglify Minify files with UglifyJS. * 
    default Alias for "watch", "uglify", "sass", "autoprefixer", "imagemin" tasks. 

私に面白い事を与える見られています。 VSコードは私にエラーを与えません。私は使用されたすべてのタスクをインストールしました。私はノードがインストールされている。

VSコードを再起動することは役に立ちません。私はこれが重要だとは思わないが、その場合にはLinuxを使用している。どちらか

+0

使用しているパッケージにnpmパッケージをインストールしましたか?例https://www.npmjs.com/package/wiredep –

+0

「npmはgrunt-comtrib-watch'をインストールしますか?はいの場合ははい、私はしました。すべての人のために – alex3wielki

+0

grunt-contrib-watchのドキュメントによれば、タスクを登録する必要はありません。 'grunt watch'を使うだけです。あなたはあなたのpackage.jsonを提供できますか?私はすべてのパッケージをインストールして何か試してみることができますか? –

答えて

1

を助けていない依存関係を再インストール

あなたでした次:

grunt.loadNpmTasks(
'grunt-contrib-uglify', 
'grunt-contrib-sass', 
'grunt-autoprefixer', 
'grunt-contrib-watch', 
'grunt-contrib-imagemin' 
); 

これでそれを置き換えます

grunt.loadNpmTasks('grunt-contrib-sass'); 
grunt.loadNpmTasks('grunt-contrib-imagemin'); 
grunt.loadNpmTasks('grunt-autoprefixer'); 
grunt.loadNpmTasks('grunt-contrib-watch'); 
grunt.loadNpmTasks('grunt-contrib-uglify'); 

うなり声が一部のgrunt.loadNpmTasksに複数の引数を取ることはありません。理由。ドキュメント内のloadNpmTasks関数の適切な使い方を見ることができます:https://gruntjs.com/sample-gruntfile

+0

うん、それだった。奇妙なことに、私はチュートリアルが1つの機能にすべて含まれていることを誓うことができました。とりあえずありがとう! – alex3wielki

関連する問題