当TFS“获取最新”插入添加开发依赖项的package.json更改时,Visual Studio 2017不会自动运行“ npm install”。这会破坏依赖新程序包的“监视”模式下的所有任务。
我看到引起npm安装的唯一方法是手动触摸package.json或重新启动VS。
是否可以在“获取最新版本”上触发“ npm安装”?
答案 0 :(得分:0)
这是我确定的解决方案的线框。 tl; dr-在Gulp中实现我自己的package.json监视程序,以停止Webpack,运行npm install
并重新启动Webpack。
const gulp = require('gulp');
const install = require('gulp-install');
const watch = require('glob-watcher');
const webpack = require('webpack');
gulp.task('default', ['webpack']);
gulp.task('webpack', function () {
// Start the initial Webpack build.
let webpackCompiler = webpack({
// ...
watch: true
// ...
});
// Set up a watcher to kill Webpack, run 'npm install', and restart Webpack when package.json changes.
let packageWatcher = watch('./package.json', { events: ['change'] }, () => {
packageWatcher.close();
console.log('Stopped package.json watcher.');
webpackWatcher.close(() => {
console.log('Stopped Webpack watcher.');
gulp.start('npm-install-then-webpack');
});
});
console.log('Started package.json watcher.');
});
gulp.task('npm-install', function (callback) {
gulp.src('./package.json')
.pipe(install(callback));
});
gulp.task('npm-install-then-webpack', ['npm-install'], function () {
gulp.start('webpack');
});