From 4831a24853a7063afdcf2e12818f71a29c3a914d Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 20 Sep 2017 23:21:45 -0700 Subject: [PATCH] yarn build script + rocket passthrough route --- src/webapp.rs | 7 ++++++- static/main.jsx | 9 +++++++-- static/package.json | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/webapp.rs b/src/webapp.rs index af53c7e..2ecc1c7 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -8,6 +8,11 @@ fn index() -> Result { NamedFile::open("static/index.html").map_err(|_| ()) } +#[get("/bundle.js")] +fn js_bundle() -> Result { + NamedFile::open("static/bundle.js").map_err(|_| ()) +} + #[derive(Serialize, Deserialize)] struct Input { source: String, @@ -25,5 +30,5 @@ fn interpreter_input(input: Json) -> Json { } pub fn web_main() { - rocket::ignite().mount("/", routes![index, interpreter_input]).launch(); + rocket::ignite().mount("/", routes![index, js_bundle, interpreter_input]).launch(); } diff --git a/static/main.jsx b/static/main.jsx index 8b6bcec..fd4b1eb 100644 --- a/static/main.jsx +++ b/static/main.jsx @@ -1,5 +1,10 @@ const React = require("react"); const ReactDOM = require("react-dom"); -const main = document.getElementById("main"); -ReactDOM.render(

Schala web input

, main); +const main = (
+

Schala web input

+

Write your source code here

+
); + +const rootDom = document.getElementById("main"); +ReactDOM.render(

Schala web input

, rootDom); diff --git a/static/package.json b/static/package.json index f8d2e57..c0d5b74 100644 --- a/static/package.json +++ b/static/package.json @@ -14,5 +14,8 @@ }, "babel": { "presets": ["babel-preset-react", "babel-preset-es2015"] + }, + "scripts": { + "build": "browserify main.jsx -t babelify -o bundle.js" } }