简体   繁体   中英

Gulp browsersync-ssi does not work

Along with browsersync, I'm working on browsersync-ssi in gulp configuration.

However, it does not work at all. Please help.

My config is as follows;

▼directory

├── app
│    ├── _stylus
│    │   └── main.styl
│    ├── img
│    ├── js
│    │   └── main.js
│    ├── ssi
│    │   └── include.html
│    └── index.ect
├── .tmp
│    └── dist
│        ├── css
│        │   └── main.css
│        └── index.html
├── gulp
│    ├── ...
│    ├── ...
│    ├── ...
│    ├── ...
│    ├── ...
│    └── browserSync.js
├── node_modules
├── bower_components
├── gulpfile.js
└── package.json

▼gulp/browserSybc.js

var gulp = require('gulp'),
    browserSync = require('browser-sync'),
    ssi = require('browsersync-ssi');

gulp.task('browser-sync', function() {

    return browserSync({
        notify: false,
        logLevel: 'silence',
        port: 9000,
        ui: {
            port: 9010
        },
        server: {
            baseDir: ['.tmp/dist/', 'app/'],
            routes: {'/bower_components': 'bower_components'},
            middleware: [
                ssi({
                    baseDir: __dirname + '/../app/ssi',
                    ext: '.html'
                })
            ]
        }
    });
});

▼.tmp/dist/index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SAMPLE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="description" content="" />

<!-- build:css css/app.css -->
<!-- bower:css -->
<link rel="stylesheet" href="/bower_components/Materialize/bin/materialize.css" />
<!-- endbower -->
<!-- inject:css -->
<link rel="stylesheet" href="/css/main.css">
<!-- endinject -->
<!-- endbuild -->

<body>

<!--#include file="/include.html" -->

<div id="content">

......

When gulp runs, the ssi discription stays as it is without including "include.html".

What is version?
This source is working.

var browserSync = require('browser-sync').create();  
var ssi = require("browsersync-ssi");

gulp.task('browser-sync', function() {  
    browserSync.init({  
        server: {  
            baseDir: "./htdocs/",  
            middleware: [  
              ssi({  
                 baseDir: __dirname + "/htdocs",  
                 ext: ".html"  
              })  
            ]  
        }  
    });  
});  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM