Permalink
Browse files

(flavor) fancy-templated-site v2.2.0

  • Loading branch information...
devinivy committed Dec 16, 2018
1 parent 8e24c92 commit 6a4cd06f8709ffc435661c8eff98c8ff223b8164
@@ -0,0 +1,2 @@
*.min.js
*.build.js
@@ -0,0 +1,39 @@
'use strict';

const ChildProcess = require('child_process');
const Util = require('util');

module.exports = [
{
type: 'onPostStart',
method: async (server) => {

if (!server.realm.pluginOptions.developmentMode) {
return;
}

const bs = server.app.bs = require('browser-sync').create();
const base = server.realm.settings.files.relativeTo;
const run = (cmd) => ChildProcess.spawn('npm', ['run', cmd], { stdio: 'inherit' });

bs.watch(`${base}/public/**/*.scss`).on('change', () => run('prebuild:css'));
bs.watch([`${base}/public/**/*.js`, '!**/*.build.*']).on('change', () => run('prebuild:js'));

bs.watch(`${base}/templates/**/*`).on('change', bs.reload);
bs.watch(`${base}/public/**/*.{build.js,css}`).on('change', bs.reload);

await Util.promisify(bs.init)({ proxy: server.info.uri });
}
},
{
type: 'onPreStop',
method: (server) => {

if (!server.app.bs) {
return;
}

server.app.bs.exit();
}
}
];
@@ -0,0 +1,3 @@
'use strict';

module.exports = __dirname;
@@ -0,0 +1,3 @@
'use strict';

module.exports = {};
@@ -0,0 +1,3 @@
'use strict';

module.exports = {};
@@ -0,0 +1,5 @@
body {
color: white;
background-color: black; }

/*# sourceMappingURL=main.build.css.map */

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1 @@
body{color:#fff;background-color:#000}
@@ -0,0 +1,4 @@
body {
color: white;
background-color: black;
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,3 @@
'use strict';

console.log('Hello, pals!');
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
method: 'get',
path: '/',
handler: {
view: {
template: 'home'
}
}
};
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
method: 'get',
path: '/public/{p*}',
handler: {
directory: {
path: 'public'
}
}
};
File renamed without changes.
@@ -0,0 +1,7 @@
{{#> layout title="Home" }}

{{#*inline "content"}}
Hello, pals! This is the homepage.
{{/inline}}

{{/layout}}
@@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<title>{{title}}</title>

{{#if options.developmentMode}}
<link rel="stylesheet" href="{{baseURI}}/public/css/main.build.css">
{{else}}
<link rel="stylesheet" href="{{baseURI}}/public/css/main.build.min.css">
{{/if}}

{{#> head-block}}
{{!-- Custom <head> content per page could be added. --}}
{{/head-block}}
</head>

<body>
{{#> content}}
{{!-- Content goes here. --}}
{{/content}}

{{#if options.developmentMode}}
<script src="{{baseURI}}/public/js/main.build.js"></script>
{{else}}
<script src="{{baseURI}}/public/js/main.build.min.js"></script>
{{/if}}

{{#> scripts-block}}
{{!-- Custom scripts per page can be added. --}}
{{/scripts-block}}
</body>
</html>
@@ -0,0 +1,18 @@
'use strict';

const Handlebars = require('handlebars');

module.exports = (server, options) => ({
path: 'templates',
partialsPath: 'templates/partials',
helpersPath: 'templates/helpers',
isCached: !options.developmentMode,
defaultExtension: 'hbs',
engines: {
hbs: Handlebars
},
context: {
options,
baseURI: server.realm.modifiers.route.prefix || ''
}
});
@@ -5,16 +5,30 @@
"scripts": {
"start": "node server",
"test": "lab -a code -L",
"lint": "eslint ."
"lint": "eslint .",
"prebuild:css": "node-sass lib/public/css/main.scss lib/public/css/main.build.css --source-map true",
"build:css": "postcss lib/public/css/main.build.css -o lib/public/css/main.build.min.css --use cssnano --no-map",
"prebuild:js": "browserify lib/public/js/main.js -o lib/public/js/main.build.js -d -t [ babelify --presets [ @babel/preset-env ] ]",
"build:js": "uglifyjs lib/public/js/main.build.js -o lib/public/js/main.build.min.js",
"build": "npm run build:css && npm run build:js"
},
"dependencies": {
"boom": "7.x.x",
"handlebars": "4.x.x",
"haute-couture": "3.x.x",
"joi": "14.x.x"
"inert": "5.x.x",
"joi": "14.x.x",
"vision": "5.x.x"
},
"devDependencies": {
"@babel/preset-env": "7.x.x",
"@babel/core": "7.x.x",
"babelify": "10.x.x",
"browser-sync": "2.x.x",
"browserify": "16.x.x",
"code": "5.x.x",
"confidence": "4.x.x",
"cssnano": "4.x.x",
"dotenv": "6.x.x",
"eslint": "5.x.x",
"eslint-config-hapi": "12.x.x",
@@ -23,6 +37,10 @@
"hapi": "17.x.x",
"hpal-debug": "1.x.x",
"lab": "18.x.x",
"toys": "2.x.x"
"node-sass": "4.x.x",
"postcss": "7.x.x",
"postcss-cli": "6.x.x",
"toys": "2.x.x",
"uglify-js": "3.x.x"
}
}
@@ -31,7 +31,13 @@ module.exports = new Confidence.Store({
plugins: [
{
plugin: '../lib', // Main plugin
options: {}
options: {
developmentMode: {
$filter: { $env: 'NODE_ENV' },
$default: true,
production: false
}
}
},
{
plugin: {

0 comments on commit 6a4cd06

Please sign in to comment.