File tree Expand file tree Collapse file tree 5 files changed +59
-1
lines changed Expand file tree Collapse file tree 5 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ module.exports = [
3737 step : "Starting the Server" ,
3838 fn : async . startServer
3939 } ,
40+ {
41+ step : "Adding serve static middlewares" ,
42+ fn : async . addServeStaticMiddleware
43+ } ,
4044 {
4145 step : "Starting the HTTPS Tunnel" ,
4246 fn : async . startTunnel
Original file line number Diff line number Diff line change @@ -182,6 +182,18 @@ module.exports = {
182182 }
183183 } ) ;
184184 } ,
185+ /**
186+ * @param bs
187+ * @param done
188+ */
189+ addServeStaticMiddleware : function ( bs , done ) {
190+ bs . options
191+ . get ( "serveStatic" )
192+ . forEach ( function ( dir ) {
193+ bs . addMiddleware ( "*" , utils . serveStatic ( dir ) ) ;
194+ } ) ;
195+ done ( ) ;
196+ } ,
185197 /**
186198 * @param {BrowserSync } bs
187199 * @param {Function } done
Original file line number Diff line number Diff line change @@ -87,6 +87,12 @@ module.exports = {
8787
8888 middleware : false ,
8989
90+ /**
91+ * Add additional directories from which static
92+ * files should be served.
93+ */
94+ serveStatic : [ ] ,
95+
9096 /**
9197 * Enable https for localhost development. **Note** - this is not needed for proxy
9298 * option as it will be inferred from your target url.
Original file line number Diff line number Diff line change 11{
22 "name" : " browser-sync" ,
33 "description" : " Live CSS Reload & Browser Syncing" ,
4- "version" : " 2.7.13 " ,
4+ "version" : " 2.8.0 " ,
55 "homepage" : " http://www.browsersync.io/" ,
66 "author" : {
77 "name" : " Shane Osbourne"
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ var browserSync = require ( "../../../index" ) ;
4+
5+ var request = require ( "supertest" ) ;
6+ var assert = require ( "chai" ) . assert ;
7+ var page = require ( "fs" ) . readFileSync ( "test/fixtures/index.html" , "utf-8" ) ;
8+
9+ describe ( "E2E `serveStatic` option" , function ( ) {
10+
11+ var bs ;
12+
13+ before ( function ( done ) {
14+ browserSync . reset ( ) ;
15+ var config = {
16+ logLevel : "silent" ,
17+ online : false ,
18+ serveStatic : [ "test/fixtures" ]
19+ } ;
20+ bs = browserSync ( config , done ) . instance ;
21+ } ) ;
22+
23+ after ( function ( ) {
24+ bs . cleanup ( ) ;
25+ } ) ;
26+
27+ it ( "can serve static files regardless of running mode" , function ( done ) {
28+ request ( bs . server )
29+ . get ( "/index.html" )
30+ . expect ( 200 )
31+ . end ( function ( err , res ) {
32+ assert . equal ( res . text , page ) ;
33+ done ( ) ;
34+ } ) ;
35+ } ) ;
36+ } ) ;
You can’t perform that action at this time.
0 commit comments