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" } }