-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
173 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import uglify from 'rollup-plugin-uglify' | ||
|
||
const babel = require('rollup-plugin-babel') | ||
const filesize = require('rollup-plugin-filesize') | ||
|
||
const pkg = require('../package.json') | ||
const external = Object.keys(pkg.dependencies) | ||
|
||
const plugins = [ | ||
babel({ | ||
presets: [ | ||
'es2015-rollup' | ||
] | ||
}), | ||
uglify(), | ||
filesize() | ||
] | ||
|
||
export default { | ||
entry: 'tram-one.js', | ||
external: external, | ||
dest: pkg.main, | ||
format: 'es', | ||
plugins: plugins, | ||
sourceMap: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import uglify from 'rollup-plugin-uglify' | ||
|
||
const commonjs = require('rollup-plugin-commonjs') | ||
const resolve = require('rollup-plugin-node-resolve') | ||
const babel = require('rollup-plugin-babel') | ||
const builtins = require('rollup-plugin-node-builtins') | ||
const globals = require('rollup-plugin-node-globals') | ||
const filesize = require('rollup-plugin-filesize') | ||
|
||
const pkg = require('../package.json') | ||
|
||
const plugins = [ | ||
resolve({ main: true, preferBuiltins: true }), | ||
commonjs(), | ||
globals(), | ||
builtins(), | ||
babel({ | ||
presets: [ | ||
'es2015-rollup' | ||
] | ||
}), | ||
uglify(), | ||
filesize() | ||
] | ||
|
||
export default { | ||
entry: 'tram-one.js', | ||
dest: pkg.browser, | ||
format: 'umd', | ||
plugins: plugins, | ||
moduleName: 'tram-one', | ||
sourceMap: true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const Tram = require('../../tram-one') | ||
const app = new Tram() | ||
const html = Tram.html() | ||
const home = () => html` | ||
<div> | ||
<h1>This is the Home Page</h1> | ||
<div> This is rendered on a server, and then served up to you! </div> | ||
<div> We also have a number page here: <a href="/num">/num</a> | ||
</div> | ||
` | ||
const num = (state) => html` | ||
<div> | ||
<h1>This is a Number Page</h1> | ||
<div> This is rendered on a server, and then served up to you! </div> | ||
<div> We can even take in stuff from the server, like this number: ${state.number} </div> | ||
</div> | ||
` | ||
|
||
app.addRoute('/', home) | ||
app.addRoute('/number', num) | ||
|
||
module.exports = app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const express = require('express') | ||
const server = express() | ||
|
||
const app = require('./index') | ||
|
||
server.get('/', (req, res) => { | ||
res.send(app.toString('/')) | ||
}) | ||
|
||
server.get('/num', (req, res) => { | ||
const number = Math.random() * 10 | ||
res.send(app.toString('/number', {number})) | ||
}) | ||
|
||
server.listen(5000, () => { | ||
console.log('ssr express server running on port 5000!') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.