これは私の問題です。contrib-copyまたはtinyimgによる変更が宛先(!)で生成された場合、livereloadは起動しましたが、ページをリロードしません。
以下のgruntfile.jsのすべてのパスはよく見られます(--verbose -vで示されています)。 LiveRoadは、ファイルを変更するたびに起動します(少なくとも--verboseはlivereloadの発生を示します)。しかし、私の/development/index.html(サブライムテキスト)または/less/mainpage.less(contrib-less)を変更した場合にのみ、ページはライブリロードされます。
私は/テスト//*、livereload火災での開発/ IMG//*またはanytingを変更するが、私のページをリロードしていない場合。
誰かが助けてくれたら本当にありがたいです。ここで
は私のフォルダ構造です:
ここsource location root: /development/
destination location root: /test/
は私gruntfile.jsです:
module.exports = function(grunt) {
grunt.initConfig({
watch: {
livereload: {
files: ['development/*.html', "test/**/*", "development/img/**/*"],
options: {
livereload: true,
spawn: false
}
},
// watch tasks start here
scripts: {
files: ['development/js/**/*.js'],
tasks: ['concat']
},
html: {
files: ['development/*.html'],
tasks: ['copy:html']
},
less_compile: {
files: ['development/a_source/less/**/*.less'],
tasks: ['less', "stripCssComments"]
},
images: {
files: ['development/img/**/*'],
tasks: ['tinyimg']
}
},
// runs local server for livereload
connect: {
sever: {
options: {
hostname: 'localhost',
port: 3000,
base: 'test/',
livereload: true
}
}
},
// *** *.html, *.img copy task here
copy: {
html: {
expand: true,
cwd: 'development',
src: '*.html',
dest: 'test/',
}
},
// *** LESS tasks here
less: {
compile: {
options: {
paths: ["development/b_components/less/"]
},
files: {
"temp/css/style.css": "development/a_source/less/style.less"
}
}
}, // compiles less and put compiled version into /temp/css/style.test
stripCssComments: {
dist: {
files: {
'test/css/style.css': 'temp/css/style.css'
}
}
}, // strips comments from /temp/css/style.css and copies it to /test/
// minify images
tinyimg: {
dynamic: {
files: [{
expand: true, // Enable dynamic expansion
cwd: 'development/img/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'test/img/' // Destination path prefix
}]
}
}
}); //initConfig
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-strip-css-comments');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-tinyimg');
grunt.registerTask('default', ["connect", "watch"]);
}; //wrapper function
機能していませんどの部分:ここで
はちょうどこのペアは私のための管理タスクを示すために私のgulpfile.jsの一例ですか? –
コメント編集に苦労して申し訳ありません:) \t ありがとうございます@Guarav_soni。さて、私はテストしました。ファイル:['test/img/*。jpg'、 'test/{、* /} * .html'、 'test/css/*'は、テンプレートのファイルパスを変更した後に部分的に機能します。 css '、' test/js/*。js ']を入力します。部分的には、イメージのライブリロードはとにかく動作しませんでした。 Watchとtinyimgはうまく動作し、test/img/*。jpgのすべての変更に対してlivereload fireを実行し、localhostにコピーされたファイルを表示します。しかし、/test/img/*.jpgが変更された場合、ページはリロードされません。 –
Chromeの開発ツールとFirefoxのインスペクタで確認しました。 grunt watchでリロードした後、ネットワークタブでピクチャのプレビューを確認すると、ピクチャは更新されません。localhost:3000/img/img1.jpgから画像をロードすると、正しいバージョンが表示されます。 –