Skip to content

Commit

Permalink
Update and document BrowserSync options
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Feb 6, 2017
1 parent 1794f9a commit 7d2d4f3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ KalaStatic can be configured through a `kalastatic.yaml` file. The default optio
# The base directory of where the base KalaStatic lives.
base: .

# What BrowserSync should consider the index page.
bsIndex: 'index.html'

# What BrowserSync should consider the webroot when running KalaStatic.
# Defaults to the KalaStatic destination directory.
bsWebroot: ''

# Whether or not to open the browser when initially running Kalastatic.
bsBrowser: false

# The directory (from base), where the source content files live.
source: src

Expand Down
16 changes: 8 additions & 8 deletions bin/kalastatic
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ program
// Build the KalaStatic application, and get the config for it.
var kalastatic = new KalaStatic(retrieveConfig(options));
var conf = kalastatic.nconf
var bsIndex = conf.get('bsIndex') || "index.html"
var bsBrowser = conf.get('browser') || false
var base = conf.get('base') || '.'
var source = conf.get('source') || 'src'
var destination = conf.get('destination') || 'build'
var bsIndex = conf.get('bsIndex')
var bsBrowser = conf.get('bsBrowser')
var base = conf.get('base')
var source = conf.get('source')
var destination = conf.get('destination')
var finalSource = path.join(base, source, '**')
var finalDest = path.join(base, destination)
var bsWebroot = conf.get('bsWebroot')

// Build KalaStatic to make sure it works first.
kalastatic.build().then(function () {
Expand All @@ -68,10 +69,9 @@ program

// Set up the server.
bs.init({
server: base,
server: bsWebroot || finalDest,
browser: bsBrowser,
index: bsIndex,
serveStatic: [base]
index: bsIndex
})

// Create a watch task.
Expand Down
2 changes: 2 additions & 0 deletions src/kalastatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ function KalaStatic(nconf) {
// Set the default values.
nconf.defaults({
base: '.',
bsIndex: 'index.html',
bsBrowser: false,
source: 'src',
destination: 'build',
plugins: [
Expand Down
11 changes: 9 additions & 2 deletions test/fixtures/start/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<h1>KalaStatic BrowserSync Watch/Start</h1>
<p>This is built from the "test/fixtures/start" directory.</p>
<ol>
<li>Run npm start</li>
<li>Open up test/fixtures/start/src/index.html.pug</li>
<li>Change something</li>
<li>See it reflet in the browser after it's built</li>
<li>WOW!</li>
</ol>
</body>
<script src="scripts.js"></script>
</html>
9 changes: 9 additions & 0 deletions test/fixtures/start/index-redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>KalaStatic Redirect</title>
<meta http-equiv="refresh" content="1;URL='./build/index.html'" />
</head>
<body>
<p>This page has moved to a <a href="./build/index.html">/build</a>.</p>
</body>
</html>
5 changes: 5 additions & 0 deletions test/fixtures/start/kalastatic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change the webroot to the currently directory.
bsWebroot: .

# Have it load the custom redirect file as the index page.
bsIndex: index-redirect.html

0 comments on commit 7d2d4f3

Please sign in to comment.