如何修复gulp注入文件

时间:2015-11-12 17:13:48

标签: html css gulp gulp-concat gulp-inject

你好

我想问一下如何才能让它在我的localhost上注入文件。 也许我在 gulpfile.js 中有问题 我试图解决它,但它不起作用 CSS& JS

<!DOCTYPE html>
<html lang="">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <title></title>
    <!-- inject:css -->
    <link rel="stylesheet" href="/assets/css/min/all-min.css">
    <!-- endinject -->
</head>


<body>

<!-- inject:js -->
<script src="/assets/js/min/all-min.js"></script>
<!-- endinject -->
</body>
</html>

gulpfile.js

   var gulp = require('gulp');
var gulputil = require('gulp-util');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var inject = require('gulp-inject');
var useref = require('gulp-useref');
var gulpif = require('gulp-if');
var browserSync = require('browser-sync').create();
var path = require('path');
//var minifyCss = require('gulp-minify-css');
var reneme =  require('gulp-rename');
var livereload = require('gulp-livereload');

gulp.task('default', function(){

});

gulp.task('index', function () {
    var target = gulp.src('index.html');
    var sources = gulp.src(['assets/js/min/*.js', 'assets/css/min/*.css'], {read: false});

    return target.pipe(inject(sources))
        .pipe(gulp.dest('./'));

});

gulp.task('js', function() {
    return gulp.src('assets/js/*.js')
        .pipe(concat('all-min.js'))
        .pipe(gulp.dest('assets/js/min'));
});

gulp.task('css', function() {
    return gulp.src('assets/css/*.css')
        .pipe(concat('all-min.css'))
        .pipe(gulp.dest('assets/css/min'));
});

enter image description here

感谢您的帮助

0 个答案:

没有答案