Skip to content

Commit

Permalink
Fix kirby-webpack for 2.5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
pqml committed Mar 2, 2018
1 parent 0b7b150 commit f930475
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div align="center">
<!-- Version -->
<a href="https://github.com/brocessing/kirby-webpack/releases"><img src="https://img.shields.io/badge/version-0.7.0-green.svg?style=flat-square" alt="Version"/></a>
<a href="https://github.com/brocessing/kirby-webpack/releases"><img src="https://img.shields.io/badge/version-0.7.4-green.svg?style=flat-square" alt="Version"/></a>
<!-- License -->
<a href="https://raw.githubusercontent.com/brocessing/kirby-webpack/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="License" /></a>
</div>
Expand Down
3 changes: 3 additions & 0 deletions main.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const devServer = {
// don't forget to rename config.localhost.php if you use a vhost
proxy: false,

// Set to true if you need a devServer in https
https: false,

// The alias/path to the php binary. OSX has PHP available natively.
// You have to edit this to have the devServer working on Windows.
// Use the proxy opt if you can't use / don't want to use a built-in php serv.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kirby-webpack",
"version": "0.7.3",
"version": "0.7.4",
"description": "A kirby starter-kit with modern frontend tools",
"main": "index.js",
"scripts": {
Expand Down
22 changes: 14 additions & 8 deletions scripts/webpack-serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,18 @@ function browserSyncInit () {
}
})

bs.init({
const BROWSERSYNC_OPTIONS = {
port: user.devServer.port || 8080,
proxy: {
target: proxyAddr,
middleware: middlewares,
proxyReq: [(proxyReq, req, res) => {
proxyReq.setHeader('X-Forwarded-For', 'webpack')
proxyReq.setHeader('X-Forwarded-Host', req.headers.host)
proxyReq.setHeader('X-Forwarded-Proto', BROWSERSYNC_OPTIONS.https ? 'https' : 'http')
}]
},
https: !!user.devServer.https,
open: false,
reloadOnRestart: true,
notify: false,
Expand All @@ -145,14 +147,18 @@ function browserSyncInit () {
path.join(user.paths.www, 'thumbs', '**/*')
].concat(user.devServer.ignored)
}
}, (error, instance) => {
if (error) throw error
// custom event for change in the www/content folder
bs.watch(path.join(user.paths.www, 'content', '**/*')).on('change', (file) => {
instance.io.sockets.emit('kirby:contentupdate', { file: file })
}

bs.init(
BROWSERSYNC_OPTIONS,
(error, instance) => {
if (error) throw error
// custom event for change in the www/content folder
bs.watch(path.join(user.paths.www, 'content', '**/*')).on('change', (file) => {
instance.io.sockets.emit('kirby:contentupdate', { file: file })
})
ready()
})
ready()
})
}

function ready () {
Expand Down
2 changes: 1 addition & 1 deletion www/site/config/config.localhost.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

// The code below are required for the kirby-webpack dev server to work
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] === 'webpack') {
c::set('url', '//' . $_SERVER['HTTP_X_FORWARDED_HOST']);
c::set('url', $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://' . $_SERVER['HTTP_X_FORWARDED_HOST']);
}

0 comments on commit f930475

Please sign in to comment.