-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsProxy.js
66 lines (53 loc) · 1.8 KB
/
bsProxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Proxy Live site and inject local files
* - run 'npm install --save-dev browser-sync'
* - change the varables below as needed
* - 'node bsProxy' to run the task
*/
//
//initialize all of our variables
var PROXY, ASSETS_DIR, REMOTE_ASSETS_PATH, REGEX, browserSync, serveStatic;
// Url of the site to be proxied
PROXY = 'https://cbufaces.cairnrepo.org';
// Root assets folder (contains /css/, /js/ etc)
ASSETS_DIR = 'dist/assets';
// Path on server to remote assets folder (escape the slashes; no trailing slash)
//REMOTE_ASSETS_PATH = '\/themes\/custom\/curiosity\/assets';
//REMOTE_ASSETS_PATH = 'https:\/\/cbufaces.cairnrepo.org\/sites\/cbufaces.cairnrepo.org\/themes\/cbu_scholar';
REMOTE_ASSETS_PATH = 'http:\/\/cbufaces.cairnrepo.org\/sites\/cbufaces.cairnrepo.org\/themes\/cbu_scholar\/dist\/assets';
//===================================
// Includes and vars
browserSync = require('browser-sync');
serveStatic = require('serve-static');
REGEX = new RegExp( REMOTE_ASSETS_PATH, 'g');
//===================================
/*
* var newpath = path.replace(/\//g, '\\/');
*/
/*
* Browsersync Task
*
*/
browserSync({
// proxy live site
proxy: PROXY,
logLevel: "debug",
//https: "true",
startPath: '/user'
// modify url of the remote assets so they point to the locally served version
//rewriteRules: [
//{
////match: /REMOTE_ASSETS_PATH/g,
//match: REGEX,
//fn: function(matched) { return '' }
////match: REGEX,
////fn: function (req, res, match) {
////return '';
////}
//}
//],
//// serve up these local files
//serveStatic: [ASSETS_DIR],
//// Watch this stuff for changes and inject it if it does
//files: ASSETS_DIR + '/**'
});