This repository was archived by the owner on Aug 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwatch.js
141 lines (120 loc) · 4.52 KB
/
watch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const { FuseBox, WebIndexPlugin, Sparky, HTMLPlugin, CSSPlugin } = require("fuse-box");
const packageName = require('./package.json').name;
// get typechecker
const typechecker = require('fuse-box-typechecker').TypeHelper({
tsConfig: './tsconfig.json',
name: 'src',
basePath: './',
tsLint: './tslint.json',
yellowOnLint: true,
shortenFilenames: true
})
// create thread
typechecker.createThread();
typechecker.options.tsConfigJsonContent.compilerOptions.paths = {
[packageName]: [
`./src/${packageName}`
]
}
let runTypeChecker = () => {
// same color..
console.log(`\x1b[36m%s\x1b[0m`, `app bundled- running type check`);
//call thread
typechecker.inspectCodeWithWorker(Object.assign(typechecker.options, { quit: false, type: 'watch' }));
typechecker.printResultWithWorker();
}
var injectBoostrapAndLoader = function () {
var loader = function () { }
loader.prototype.init = function (context) { }
loader.prototype.bundleEnd = function (context) {
context.source.addContent(`FuseBox.import("fuse-box-aurelia-loader")`);
context.source.addContent(`FuseBox.import("aurelia-bootstrapper")`);
context.source.addContent(`window.FUSEBOX_AURELIA_LOADER_RELOAD = true;`);
context.source.addContent(`window.FUSEBOX_AURELIA_LOADER_LOGGING = true;`);
}
return new loader();
}
// variables
let fuse, bundle;
let isProduction = false;
let target = "browser@es6";
let bundleName = "app";
let instructions = `
> sample/main.ts
+ **/*.{ts,html,css}
+ fuse-box-css
+ aurelia-bootstrapper
+ aurelia-framework
+ aurelia-pal
+ aurelia-metadata
+ aurelia-loader-default
+ aurelia-polyfills
+ aurelia-fetch-client
+ aurelia-pal-browser
+ aurelia-animator-css
+ aurelia-logging-console
+ aurelia-templating-binding
+ aurelia-templating-resources
+ aurelia-event-aggregator
+ aurelia-history-browser
+ aurelia-templating-router
+ fuse-box-aurelia-loader`;
let webIndexTemplate =
`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome to Aurelia with FuseBox</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body aurelia-app="sample/main"></body>
<script type="text/javascript" charset="utf-8" src="./app.js"></script>
</html>`
Sparky.task("config", () => {
fuse = FuseBox.init({
homeDir: "src",
globals: { 'default': '*' }, // we need to expore index in our bundles
target: target,
output: "dev/$name.js",
cache: false,
log: false,
tsConfig: [{ // override tsConfig
target: bundleName,
"paths": {
[packageName]: [
`./src/${packageName}`
]
}
// todo: override path, not possible atm (only in typechecker...)
}],
alias: { [packageName]: `~/${packageName}` }, // <- why cant I have `~/plugin` <-is that a bug ?
plugins: [
injectBoostrapAndLoader(),
CSSPlugin(),
HTMLPlugin(),
WebIndexPlugin({ templateString: webIndexTemplate })
]
})
fuse.bundle(bundleName)
.instructions(instructions)
.sourceMaps(true)
.watch()
.completed(proc => {
runTypeChecker();
});
});
Sparky.task("clean", () => {
return Sparky.src("dev/").clean("dev/");
});
Sparky.task("default", ["clean", "config"], () => {
fuse.dev();
fuse.run();
});
// load
var TypeHelper = require('fuse-box-typechecker').TypeHelper
// it checks entire program every time
// see interface at bottom at readme for all options