From db529d0821ca522bc849fa97b6faefe8c8248234 Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Thu, 12 Oct 2017 17:54:25 +0200 Subject: [PATCH] feat(template-minimal): add a minimal example template without react --- packages/template-minimal/.gitignore | 6 ++++++ packages/template-minimal/package.json | 24 ++++++++++++++++++++++++ packages/template-minimal/readme.md | 24 ++++++++++++++++++++++++ packages/template-minimal/src/browser.js | 11 +++++++++++ packages/template-minimal/src/server.js | 23 +++++++++++++++++++++++ packages/template-minimal/src/styles.css | 3 +++ 6 files changed, 91 insertions(+) create mode 100644 packages/template-minimal/.gitignore create mode 100644 packages/template-minimal/package.json create mode 100644 packages/template-minimal/readme.md create mode 100644 packages/template-minimal/src/browser.js create mode 100644 packages/template-minimal/src/server.js create mode 100644 packages/template-minimal/src/styles.css diff --git a/packages/template-minimal/.gitignore b/packages/template-minimal/.gitignore new file mode 100644 index 000000000..f363b5bdb --- /dev/null +++ b/packages/template-minimal/.gitignore @@ -0,0 +1,6 @@ +.tmp +build +docs +node_modules +*.log +.DS_Store diff --git a/packages/template-minimal/package.json b/packages/template-minimal/package.json new file mode 100644 index 000000000..3a6c19307 --- /dev/null +++ b/packages/template-minimal/package.json @@ -0,0 +1,24 @@ +{ + "name": "hops-template-minimal", + "version": "7.0.0-2", + "browser": "src/browser.js", + "server": "src/server.js", + "license": "MIT", + "config": { + "hops": { + "browsers": "last 1 Chrome versions" + } + }, + "scripts": { + "start": "hops start", + "build": "hops build" + }, + "dependencies": { + "hops-config": "7.0.0-0", + "hops-express": "7.0.0-1", + "hops-local-cli": "7.0.0-2" + }, + "devDependencies": { + "hops-build": "7.0.0-2" + } +} diff --git a/packages/template-minimal/readme.md b/packages/template-minimal/readme.md new file mode 100644 index 000000000..87208a371 --- /dev/null +++ b/packages/template-minimal/readme.md @@ -0,0 +1,24 @@ +# Hops Template Minimal + +This is a minimal example of how [hops](https://github.com/xing/hops) can be used without react. + + +## Target audience + +You might want to use this if you plan to use something other than react, for example when you want to build a vue.js or preact application - or if you disagree with / want to make more extensive customizations than those done in [hops-react](https://github.com/xing/hops/tree/master/packages/react) and [hops-redux](https://github.com/xing/hops/tree/master/packages/redux). + + +## Overview + +#### browser.js + +This script (and all of its dependencies) will be bundled through webpack into the `main-[hash].js` bundle located at [hops-config](https://github.com/xing/hops/tree/master/packages/config)s `buildDir`. + +It will then be requested by the browser because the [server](#server.js) embeds it into the intial HTML response. + + +#### server.js + +This script (and all of its dependencies) will be bundled through webpack into the `server.js` bundle located at [hops-config](https://github.com/xing/hops/tree/master/packages/config)s `cacheDir`. + +It will then be used as a Express.js-style middleware for [hops-express](https://github.com/xing/hops/tree/master/packages/express) and the `webpack-dev-server` contained in [hops-build](https://github.com/xing/hops/tree/master/packages/build). diff --git a/packages/template-minimal/src/browser.js b/packages/template-minimal/src/browser.js new file mode 100644 index 000000000..37cf9aa40 --- /dev/null +++ b/packages/template-minimal/src/browser.js @@ -0,0 +1,11 @@ +import styles from './styles.css'; + +export default () => { + const root = document.getElementById('app'); + + const headline = document.createElement('h1'); + headline.innerText = 'Hello Hops!'; + headline.className = styles.headline; + + root.appendChild(headline); +}; diff --git a/packages/template-minimal/src/server.js b/packages/template-minimal/src/server.js new file mode 100644 index 000000000..1fdfd75cd --- /dev/null +++ b/packages/template-minimal/src/server.js @@ -0,0 +1,23 @@ +import hopsConfig from 'hops-config'; + +export default (req, res, next) => { + res.send( +` + + + Hello Hops + ${hopsConfig.assets.css.map(css => + `` + ).join('')} + + +
+ + ${hopsConfig.assets.js.map(js => + `` + ).join('')} + + +` + ); +}; diff --git a/packages/template-minimal/src/styles.css b/packages/template-minimal/src/styles.css new file mode 100644 index 000000000..23983d06b --- /dev/null +++ b/packages/template-minimal/src/styles.css @@ -0,0 +1,3 @@ +.headline { + color: blue; +}