-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
type: feat | added support for browser sync
- Loading branch information
Showing
5 changed files
with
3,289 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
*config.yml | ||
*.env | ||
*node_modules/ | ||
*theme.update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Browser-sync config file | ||
|-------------------------------------------------------------------------- | ||
| | ||
| For up-to-date information about the options: | ||
| http://www.browsersync.io/docs/options/ | ||
| | ||
| There are more options than you see here, these are just the ones that are | ||
| set internally. See the website for more info. | ||
| | ||
| | ||
*/ | ||
const yaml = require('js-yaml'); | ||
const fs = require('fs'); | ||
|
||
try { | ||
let fileData = fs.readFileSync('./dist/config.yml', 'utf8'); | ||
const themeConfig = yaml.safeLoad(fileData); | ||
|
||
//development theme config | ||
var id = themeConfig.development.theme_id; | ||
var store = themeConfig.development.store; | ||
} catch (e) { | ||
console.log('\x1b[33m%s\x1b[0m', 'Could not read config.yml, Make Sure you have a config in ./dist/config.yml'); | ||
throw new Error(e); | ||
} | ||
|
||
module.exports = { | ||
proxy: `https://${store}?preview_theme_id=${id}&pb=0&_fd=0`, | ||
files: 'theme.update', | ||
reloadDelay: 100, | ||
snippetOptions: { | ||
rule: { | ||
match: /<head[^>]*>/i, | ||
fn(snippet, match) { | ||
return match + snippet; | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.