yarn build script + rocket passthrough route

This commit is contained in:
greg 2017-09-20 23:21:45 -07:00
parent 67ff21d408
commit 4831a24853
3 changed files with 16 additions and 3 deletions

View File

@ -8,6 +8,11 @@ fn index() -> Result<NamedFile, ()> {
NamedFile::open("static/index.html").map_err(|_| ())
}
#[get("/bundle.js")]
fn js_bundle() -> Result<NamedFile, ()> {
NamedFile::open("static/bundle.js").map_err(|_| ())
}
#[derive(Serialize, Deserialize)]
struct Input {
source: String,
@ -25,5 +30,5 @@ fn interpreter_input(input: Json<Input>) -> Json<Output> {
}
pub fn web_main() {
rocket::ignite().mount("/", routes![index, interpreter_input]).launch();
rocket::ignite().mount("/", routes![index, js_bundle, interpreter_input]).launch();
}

View File

@ -1,5 +1,10 @@
const React = require("react");
const ReactDOM = require("react-dom");
const main = document.getElementById("main");
ReactDOM.render(<h1>Schala web input</h1>, main);
const main = (<div>
<h1>Schala web input</h1>
<p>Write your source code here</p>
</div>);
const rootDom = document.getElementById("main");
ReactDOM.render(<h1>Schala web input</h1>, rootDom);

View File

@ -14,5 +14,8 @@
},
"babel": {
"presets": ["babel-preset-react", "babel-preset-es2015"]
},
"scripts": {
"build": "browserify main.jsx -t babelify -o bundle.js"
}
}