我刚开始使用Gulp,但遇到了一个无法找到任何解决方案的问题。我已经阅读了有关此问题的每个问题,但没有任何解决方案。我也在使用XAMPP和虚拟主机。
这是gulpfile.js
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var styleSrc = "./resources/scss";
gulp.task('default', ['watch','sass'], function(){});
// Watch for changes
gulp.task('watch', function(){
// Serve files from the root of this project
browserSync.init({
proxy: 'starter.web'
});
gulp.watch(styleSrc,['sass']).on('change', browserSync.reload);
gulp.watch('./public/*.php').on('change', browserSync.reload);
});
gulp.task('sass', function(){
return gulp.src('./resources/scss/main.scss')
.pipe(sass())
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.reload({ stream: true }))
});
问题是,当我启动gulp时,它将scss文件编译为css并启动browserSync,然后,如果我更改了php文件中的任何内容,就可以了,但是如果我更改了scss文件中的任何内容,这是我得到的输出:
cmd.exe /D /C call "C:\Users\User\AppData\Roaming\npm\sass.cmd" --no-cache --update main.scss:main.css
Could not find an option named "cache".
Usage: sass <input.scss> [output.css]
sass <input.scss>:<output.css> <input/>:<output/>
=== Input and Output ===================
--[no-]stdin Read the stylesheet from stdin.
--[no-]indented Use the indented syntax for input from stdin.
-I, --load-path=<PATH> A path to use when resolving imports.
May be passed multiple times.
-s, --style=<NAME> Output style.
[expanded (default), compressed]
--update Only compile out-of-date stylesheets.
=== Source Maps ========================
--[no-]source-map Whether to generate source maps.
(defaults to on)
--source-map-urls How to link from source maps to source files.
[relative (default), absolute]
--[no-]embed-sources Embed source file contents in source maps.
--[no-]embed-source-map Embed source map contents in CSS.
=== Other ==============================
--watch Watch stylesheets and recompile when they change.
--[no-]poll Manually check for changes rather than using a native watcher.
Only valid with --watch.
--[no-]stop-on-error Don't compile more files once an error is encountered.
-i, --interactive Run an interactive SassScript shell.
-c, --[no-]color Whether to emit terminal colors.
-q, --[no-]quiet Don't print warnings.
--[no-]trace Print full Dart stack traces for exceptions.
-h, --help Print this usage information.
--version Print the version of Dart Sass.
Process finished with exit code 64
它不会重新编译它。任何人都知道发生了什么事吗?
答案 0 :(得分:1)
不是专家吗?
我假设您正在使用口香糖3
您的代码应为
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var styleSrc = "./resources/scss";
gulp.task('sass', function(){
return gulp.src('./resources/scss/main.scss')
.pipe(sass())
.pipe(gulp.dest('./public/css'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('browser-sync',['sass'] function() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch(styleSrc, ['sass']);
gulp.watch("./public/*.php").on('change', browserSync.reload);
});
gulp.task('default', ['sass', 'browser-sync']
将此用作您的gulpfile.js
然后运行gulp