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
5 changed files
with
85 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const { FuseBox, Sparky, WebIndexPlugin, QuantumPlugin } = require("fuse-box"); | ||
const { src, task, watch, context, fuse } = require("fuse-box/sparky"); | ||
|
||
|
||
context(class { | ||
getConfig() { | ||
return FuseBox.init({ | ||
homeDir: "src", | ||
output: "dist/$name.js", | ||
target: "browser@es5", | ||
hash: this.isProduction, | ||
plugins: [ | ||
WebIndexPlugin(), | ||
this.isProduction && QuantumPlugin({ | ||
bakeApiIntoBundle: "app", | ||
uglify: true, | ||
extendServerImport: true | ||
}) | ||
] | ||
}) | ||
} | ||
createBundle(fuse) { | ||
const app = fuse.bundle("app"); | ||
if (!this.isProduction) { | ||
app.watch() | ||
app.hmr() | ||
} | ||
app.instructions(">index.ts"); | ||
return app; | ||
} | ||
}); | ||
task("clean", () => src("dist").clean("dist").exec() ) | ||
|
||
task("launch-server", async context => { | ||
const server = FuseBox.init({ target: "server", homeDir: "server", output: "dist/server/$name.js" }) | ||
server.bundle("server") | ||
.completed(proc => proc.start()) | ||
.instructions(">[server.ts]").watch() | ||
await server.run(); | ||
}); | ||
|
||
task("default", ["clean", "launch-server"], async context => { | ||
const fuse = context.getConfig(); | ||
fuse.dev({ httpServer: false }); | ||
context.createBundle(fuse); | ||
await fuse.run(); | ||
}); | ||
|
||
task("dist", ["clean", "launch-server"], async context => { | ||
context.isProduction = true; | ||
const fuse = context.getConfig(); | ||
fuse.dev(); // remove it later | ||
context.createBundle(fuse); | ||
await fuse.run(); | ||
}); |
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,9 @@ | ||
import * as express from "express"; | ||
import * as path from "path"; | ||
|
||
const app = express() | ||
|
||
app.use(express.static(path.resolve("dist"))) | ||
|
||
|
||
app.listen(3000, () => console.log('Example app listening on port 3000!')) |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "ES6", | ||
"jsx": "react", | ||
"importHelpers": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": 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 @@ | ||
console.log("hello world"); |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "ES5", | ||
"jsx": "react", | ||
"importHelpers": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true | ||
} | ||
} |