This repository has been archived by the owner on Apr 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
watch.js
182 lines (161 loc) · 4.84 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// @ts-check
/**
* This takes care of the watch script, uses fusebox as loader/bundler
*
*/
const {
FuseBox,
QuantumPlugin,
WebIndexPlugin,
Sparky,
HTMLPlugin,
CSSPlugin,
RawPlugin
} = require('fuse-box');
// @ts-ignore
const FOLDER_NAME = require('../package.json').folder_name;
// @ts-ignore
const PACKAGE_NAME = require('../package.json').name;
const {
runTypeChecker
} = require('./typechecker');
const {
bootstrapLoader
} = require('./bootstrapLoader');
let fuse_sample, fuse_plugin, target = 'browser@es6';
// add your vendor packages in here
let instructions = `
> extra.ts
+ fuse-box-css
+ aurelia-bootstrapper
+ aurelia-binding
+ 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
+ @aurelia-toolbelt/core
+ fast-safe-stringify
+ inputmask
+ markdown-it
+ jalali-moment
+ humanize-duration
+ numeral
`;
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="main"></body>
<script type="text/javascript" charset="utf-8" src="./vendor.js"></script>
<script type="text/javascript" charset="utf-8" src="./app.js"></script>
<script type="text/javascript" charset="utf-8" src="./${FOLDER_NAME}.js"></script>
</html>`;
Sparky.task('config', () => {
fuse_sample = FuseBox.init({
homeDir: '../src/sample',
globals: {
'default': '*'
},
target: target,
output: '../dev/$name.js',
cache: false,
log: false,
debug: false,
alias: {
[FOLDER_NAME]: `~/${FOLDER_NAME}`
},
// Need to be the same..(alias cant be anything since its really on transpile fusebox does this)
plugins: [
bootstrapLoader(),
CSSPlugin(),
HTMLPlugin(),
RawPlugin(['.css', '.woff']),
WebIndexPlugin({
templateString: webIndexTemplate
})
]
});
fuse_sample.register('@aurelia-toolbelt/core', {
homeDir: '../../../node_modules/@aurelia-toolbelt/core/dist/commonjs',
main: 'index.js',
instructions: '**/*.{html,css,js}',
});
fuse_sample.bundle(`vendor`)
.cache(false)
// .shim({
// jquery: {
// source: "node_modules/jquery/dist/jquery.js",
// exports: "$"
// }
// })
.instructions(instructions);
fuse_sample.bundle('app')
.instructions(`
> [main.ts]
+ [**/*.{ts,html,css}]
`)
.sourceMaps(true)
.watch()
.completed(proc => {
runTypeChecker();
});
fuse_plugin = FuseBox.init({
homeDir: `../src/${FOLDER_NAME}`,
// globals: {
// '@aut/shahab': '*'
// },
target: target,
output: '../dev/$name.js',
cache: false,
log: false,
alias: {
[FOLDER_NAME]: `~/${FOLDER_NAME}`
},
// Need to be the same..(alias cant be anything since its really on transpile fusebox does this)
plugins: [
bootstrapLoader(),
CSSPlugin(),
HTMLPlugin()
],
package: {
name: `${PACKAGE_NAME}`,
main: "index.ts" // if your package start point file is different change it here
}
});
// the name of the output file as specified $name in output part of init method
fuse_plugin.bundle(`${FOLDER_NAME}`)
.watch().cache(false)
.instructions(`
+ [**/*.html]
+ [**/*.ts]
+ [**/*.js]
+ [**/*.css]
`).sourceMaps(true);
});
Sparky.task('clean', () => {
return Sparky.src('../dev/').clean('../dev/');
});
Sparky.task('default', ['clean', 'config'], () => {
fuse_plugin.run();
fuse_sample.dev();
fuse_sample.run();
});