如何附加到 { asset ('/') }, prefix URL build gulp-useref task on my includable page

How to append to { asset ('/') }, prefix URL build gulp-useref task on my an includable page

我用了gulp和Laravelblade当运行gulp,

我要东西吗?

我想要 {{ asset('/') }} 附加到前缀 URL build


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

...
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 运行ning gulp

<link rel="stylesheet" href="resources/assets/css/out.css">

But i want it:

i want {{ asset('/') }} append to perfix url build

head-include.blade.php 我要..

<link rel="stylesheet" href="{{ asset('/') }} resources/assets/css/out.css">

安装gulp-replace

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 -->