Skip to content

Commit

Permalink
Fix configuration for webpack dev server
Browse files Browse the repository at this point in the history
  • Loading branch information
start committed Sep 1, 2019
1 parent d23a9fe commit 6a2dc0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"description": "The official site for [Up](https://github.com/start/up), a lightweight markup language for writing structured content for the web.",
"scripts": {
"start": "webpack-dev-server --content-base docs/ --inline --hot --host 0.0.0.0",
"start": "webpack-dev-server",
"build": "rm -f docs/{index.html,*.js} && webpack"
},
"repository": {
Expand Down
26 changes: 17 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const fs = require('fs')
const Up = require('up-lang')
const upSettings = require('./src/upSettings')
const { resolve } = require('path')
const path = require('path')

const documentationMarkup =
fs.readFileSync(sourceDir('content/documentation.up'), 'utf-8')
fs.readFileSync(fromSourceDir('content/documentation.up'), 'utf-8')

const renderedUp =
Up.parseAndRenderWithTableOfContents(documentationMarkup, upSettings)

const outputDir = path.resolve('./docs');

module.exports = {
entry: sourceDir('app.js'),
entry: fromSourceDir('app.js'),
output: {
path: resolve('./docs'),
path: outputDir,
filename: 'bundle-[hash].js'
},
module: {
Expand Down Expand Up @@ -44,19 +46,25 @@ module.exports = {
test: /\.up$/,
use: 'raw-loader',
}
]
],
},
plugins: [
new HtmlWebpackPlugin({
template: sourceDir('layout/index.hbs'),
template: fromSourceDir('layout/index.hbs'),
documentationHtml: renderedUp.documentHtml,
tableOfContentsHtml: renderedUp.tableOfContentsHtml,
inject: 'head'
})
]
],
devServer: {
contentBase: outputDir,
compress: true,
port: 9000,
open: true
}
}


function sourceDir(path) {
return './src/' + path
function fromSourceDir(pathAndFilename) {
return path.resolve('src', pathAndFilename)
}

0 comments on commit 6a2dc0e

Please sign in to comment.