mframejs
Version:
simple framework
98 lines (83 loc) • 3.42 kB
JavaScript
/*
* This build an starts
*/
const { task, src } = require('fuse-box/sparky');
const { FuseBox, WebIndexPlugin, HTMLPlugin, CSSPlugin } = require("fuse-box");
const fs = require('fs');
let typechecker, fuse;
let webIndexTemplate =
`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>mframejs</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" ">
<script type="text/javascript" charset="utf-8" src="./app.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
</html>`
task("start-typechecker", () => {
typechecker = require('fuse-box-typechecker').TypeChecker({
tsConfig: './tsconfig.json',
name: 'src',
basePath: './',
tsLint: './tslint.json',
yellowOnLint: true,
shortenFilenames: true,
tsConfigOverride: {
exclude: [
"node_modules",
"dist",
"distTS",
"test",
"sample-base"
],
}
});
// this just starts the typechecker and waits for call to run typecheck
typechecker.startTreadAndWait();
});
task("config", () => {
fuse = FuseBox.init({
homeDir: "../src",
globals: { 'default': '*' }, // we need to expore index in our bundles
target: "browser@es6",
output: "../dev/$name.js",
cache: false,
log: false,
alias: { mframejs: "~/mframejs" },
plugins: [
CSSPlugin(),
HTMLPlugin(),
WebIndexPlugin({ templateString: webIndexTemplate })
]
})
fuse.bundle("app")
.instructions(`
> sample/index.ts
+ **/*.{ts,html,css}`)
.sourceMaps(true)
.watch()
.completed(proc => {
console.log(`\x1b[36m%s\x1b[0m`, `app bundled- running type check`);
typechecker.useThreadAndTypecheck();
});
});
task("clean", () => {
return src("../dev/").clean("../dev/");
});
task("create-sample", () => {
if (!fs.existsSync("./src/sample/")) {
return src('**/*.*', { base: '../src/sample-base' }).dest('..//src/sample').exec();
} else {
return;
}
});
task("default", ["create-sample", "clean", "start-typechecker", "config"], () => {
fuse.dev();
fuse.run();
});