我正在使用聚合物和重新加载文件的变化手动。因此,我尝试使用browser-sync
和browser-sync with gulp
,但无法成功。
我尝试了两种方法:
1) npm脚本 in package.json
"scripts": {
"dev": "polymer serve | npm run watch",
"watch": "browser-sync start --proxy localhost:8080 --files 'src/*.html, src/*.js, images/*' "
},
使用npm run dev
运行它,它会运行,但无法检测文件中的更改。
2) 与浏览器同步结合使用gulp。
var gulp = require('gulp');
var bs = require('browser-sync').create();
gulp.task('browser-sync', function() {
bs.init({
port : 5000,
proxy: {
target : "localhost:8080"
}
});
});
gulp.task('watch', ['browser-sync'], function () {
gulp.watch("*.html").on('change', bs.reload);
});
它也运行,但无法检测*.html
文件中的更改,该文件存在于src
文件夹中。
有人能帮我解释一下为什么没有检测到文件的变化。
发布于 2017-01-26 14:05:44
我自己也知道,我在npm scripts
上犯了一个小错误。我已修改为:
"scripts": {
"dev": "polymer serve --port 8081 | npm run watch",
"test": "polymer test",
"watch": "browser-sync start --proxy localhost:8081 --files \"src/**/*.*, index.html, *.js\""
},
现在一切都好了!!
https://stackoverflow.com/questions/41825644
复制相似问题