【发布时间】:2019-03-03 18:32:06
【问题描述】:
我最近开始使用 Laravel 进行开发,但很快就遇到了使用 Gulp 和 Vagrant 的问题。问题是当我将我的 SCSS (SASS) 编译为 css 时,浏览器似乎没有更新 css 文件。该文件正在 vagrant 中正确同步,并且不会被 NGINX 缓存。我知道这一点是因为我在服务器端禁用了缓存并检查了同步文件夹 /var/www/my-project/public/css 文件夹以查看文件是否正确编译。
文件只有在我重新加载 vagrant box 时才能正确加载,这很奇怪,因为同步文件夹在服务器上显示了正确编译的文件。清除浏览器中的缓存无济于事。我不知道问题出在哪里。我使用谷歌浏览器。
在我的服务器块和 Gulpfile 下方:
NGINX 服务器块(注意这不是 Laravel 家园):
location / {
try_files $uri $uri/ /index.php;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, $date, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}
location ~ /\.ht {
deny all;
}
Gulp 任务:
gulp.task("sass", function () {
gulp.src(path.sass.src)
.pipe(plumber({
errorHandler: function (err) {
console.log(err.message);
this.emit("end");
}
}))
.pipe(sass())
.pipe(gulp.dest(path.sass.destination))
.pipe(notify({
message: "Sass compiled.",
onLast: true
}));
});
希望有人能帮帮我。
【问题讨论】:
-
尝试运行
php artisan view:clear -
不幸的是这不起作用:( @JPark
标签: php laravel nginx gulp vagrant