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

25
node_modules/bs-recipes/recipes/server.includes/app.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
/**
* Require Browsersync
*/
var browserSync = require('browser-sync').create();
var fs = require('fs');
/**
* Run Browsersync with server config
*/
browserSync.init({
server: 'app',
files: ['app/*.html', 'app/css/*.css'],
rewriteRules: [
{
match: /@include\("(.+?)"\)/g,
fn: function (match, filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename);
} else {
return '<span style="color: red">'+filename+' could not be found</span>';
}
}
}
]
});

View File

@ -0,0 +1,4 @@
body {
background: white;
color: black;
}

View File

@ -0,0 +1,3 @@
<footer>
<p class="copyright">Copyright</p>
</footer>

View File

@ -0,0 +1,3 @@
<header>
<h1>Some title!</h1>
</header>

View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Browsersync Server Includes Example</title>
<link rel='stylesheet' href='css/main.css'>
</head>
<body>
@include("app/header.html")
<h1>Browsersync Server Includes Example</h1>
@include("app/footer.html")
</body>
</html>

View File

View File

@ -0,0 +1,13 @@
{
"name": "bs-recipes-server-includes",
"version": "1.0.0",
"description": "Server includes example",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"license": "MIT",
"dependencies": {
"browser-sync": "^2.1.6"
}
}

View File

@ -0,0 +1,59 @@
#Browsersync - Server includes 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.includes
```
**Step 3**: Install dependencies
```bash
$ npm install
```
**Step 4**: Run the example
```bash
$ npm start
```
### Additional Info:
### Preview of `app.js`:
```js
/**
* Require Browsersync
*/
var browserSync = require('browser-sync').create();
var fs = require('fs');
/**
* Run Browsersync with server config
*/
browserSync.init({
server: 'app',
files: ['app/*.html', 'app/css/*.css'],
rewriteRules: [
{
match: /@include\("(.+?)"\)/g,
fn: function (match, filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename);
} else {
return '<span style="color: red">'+filename+' could not be found</span>';
}
}
}
]
});
```