我正在玩Angular 2,使用官方Quick start指南。在scss上重新加載頁面保存
Dev package.json文件的依賴項允許通過保存html文件實時重新加載。
我也使用Gulp和生活重新加載scss來裝飾我的東西的CSS。
我想要的是將Gulp的scss live reload與Angular 2的html live reload進行綁定。我的意思是,當我將更改保存在scss或html文件中時,我希望通過實時重新加載來完成這些更改。
現在我只能通過在終端中運行Gulp命令或npm start命令來分別進行scss和html更改。
我gulpfile.js代碼:
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function(){
return gulp.src('app/assets/scss/styles.scss')
.pipe(sass())
.pipe(gulp.dest('app/assets/css'))
});
我的package.json代碼:
{
"name": "app",
"version": "1.0.0",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"browser-sync": "^2.16.0",
"concurrently": "^2.2.0",
"gulp": "^3.9.1",
"gulp-sass": "^2.3.2",
"lite-server": "^2.2.2",
"typescript": "^2.0.2",
"typings": "^1.3.2"
}
}
本教程介紹瞭如何編譯SCSS的CSS,甚至做現場重裝:https://medium.com/@lampt2509/set-up-persistence-scss -from-chrome-devtools-for-angular-220ce0818568 –