This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

View File

@ -0,0 +1,19 @@
/**
* Require Browsersync
*/
var browserSync = require('browser-sync').create();
var middleware = require('connect-gzip-static')('./app');
/**
* Run Browsersync with server config
* Add middleware with override:true to ensure all files are
* picked up.
*/
browserSync.init({
server: 'app',
files: ['app/*.html', 'app/css/*.css']
}, function (err, bs) {
bs.addMiddleware("*", middleware, {
override: true
});
});

Binary file not shown.

View File

@ -0,0 +1,11 @@
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Browsersync Server + Gzipped assets Example</title>
<link rel='stylesheet' href='css/main.css'>
</head>
<body>
<h1>Browsersync Server + Gzipped assets Example</h1>
</body>
</html>

View File

@ -0,0 +1,3 @@
This example shows how you can use the `connect-gzip-static` middleware
to serve already-gzipped assets.

View File

@ -0,0 +1,14 @@
{
"name": "bs-recipes-server-with-gzipped-assets",
"version": "1.0.0",
"description": "Server with pre-gzipped assets example",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"license": "MIT",
"dependencies": {
"browser-sync": "^2.4.0",
"connect-gzip-static": "^1.0.0"
}
}

View File

@ -0,0 +1,56 @@
#Browsersync - Server with pre-gzipped assets example
## Installation/Usage:
To try this example, follow these 4 simple steps.
**Step 1**: Clone this entire repo
```bash
$ git clone https://github.com/Browsersync/recipes.git bs-recipes
```
**Step 2**: Move into the directory containing this example
```bash
$ cd bs-recipes/recipes/server.gzipped.assets
```
**Step 3**: Install dependencies
```bash
$ npm install
```
**Step 4**: Run the example
```bash
$ npm start
```
### Additional Info:
This example shows how you can use the `connect-gzip-static` middleware
to serve already-gzipped assets.
### Preview of `app.js`:
```js
/**
* Require Browsersync
*/
var browserSync = require('browser-sync').create();
var middleware = require('connect-gzip-static')('./app');
/**
* Run Browsersync with server config
* Add middleware with override:true to ensure all files are
* picked up.
*/
browserSync.init({
server: 'app',
files: ['app/*.html', 'app/css/*.css']
}, function (err, bs) {
bs.addMiddleware("*", middleware, {
override: true
});
});
```