[英]How to append to { asset ('/') }, prefix URL build gulp-useref task on my an includable page
I used gulp and Laravel blade when run gulp, 我在运行gulp时使用了gulp和Laravel刀片,
Do I want thing? 我想要东西吗?
I want {{ asset('/') }} append to perfix URL build 我想将{{asset('/')}}附加到perfix URL构建
head-include.blade.php Before running gulp head-include.blade.php 在运行gulp 之前
<!-- build:css resources/assets/css/out.css -->
<link rel="stylesheet" href="resources/assets/css/1.css">
<link rel="stylesheet" href="resources/assets/css/2.css">
<!-- endbuild -->
gulpfiles.js gulpfiles.js
...
gulp.task('useref', function(){
return gulp.src(paths.assets.html)
.pipe(useref())
.pipe(gulpIf('*.js', uglify()))
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest(paths.dev.html))
});
...
head-include.blade.php After running gulp 运行gulp 后, head-include.blade.php
<link rel="stylesheet" href="resources/assets/css/out.css">
But i want it:
但我想要它:
i want {{ asset('/') }} append to perfix url build
我想要{{asset('/')}}附加到perfix url构建
head-include.blade.php I want .. 我想要 head-include.blade.php ..
<link rel="stylesheet" href="{{ asset('/') }} resources/assets/css/out.css">
install gulp-replace 安装gulp-replace
npm install gulp-replace --save-dev
npm install gulp-replace --save-dev
replace = require('gulp-replace');
gulp.task('useref', function(){
return gulp.src(paths.assets.view)
.pipe(replace("{{ asset('resources/assets') }}", 'resources/assets'))
.pipe(useref())
// Minifies only if it's a JavaScript file
.pipe(gulpIf('*.js', uglify()))
// Minifies only if it's a CSS file
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest(paths.dev.view))
.pipe(replace('../assets', "{{ asset('resources/assets') }}"))
.pipe(gulp.dest(paths.dev.view))
});
<!-- build:css(./) resources/assets/css/out.css -->
<link rel="stylesheet" href="{{ asset('resources/assets') }}/css/1.css">
<link rel="stylesheet" href="{{ asset('resources/assets') }}/css/2.css">
<!-- endbuild -->
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.