2019-12-29 21:06:04 +00:00
|
|
|
const {
|
2019-03-21 01:22:31 +00:00
|
|
|
FuseBox,
|
|
|
|
Sparky,
|
|
|
|
EnvPlugin,
|
|
|
|
CSSPlugin,
|
|
|
|
WebIndexPlugin,
|
2019-12-29 20:39:48 +00:00
|
|
|
QuantumPlugin,
|
2020-08-11 21:09:41 +00:00
|
|
|
BannerPlugin,
|
2019-12-29 21:06:04 +00:00
|
|
|
} = require('fuse-box');
|
2019-03-21 01:22:31 +00:00
|
|
|
const transformInferno = require('ts-transform-inferno').default;
|
|
|
|
const transformClasscat = require('ts-transform-classcat').default;
|
|
|
|
let fuse, app;
|
|
|
|
let isProduction = false;
|
2020-08-11 21:09:41 +00:00
|
|
|
let libreJsLicense =
|
|
|
|
'// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt GNU Affero General Public License, version 3';
|
2019-03-21 01:22:31 +00:00
|
|
|
|
|
|
|
Sparky.task('config', _ => {
|
|
|
|
fuse = new FuseBox({
|
|
|
|
homeDir: 'src',
|
|
|
|
hash: isProduction,
|
|
|
|
output: 'dist/$name.js',
|
|
|
|
experimentalFeatures: true,
|
|
|
|
cache: !isProduction,
|
|
|
|
sourceMaps: !isProduction,
|
|
|
|
transformers: {
|
|
|
|
before: [transformClasscat(), transformInferno()],
|
|
|
|
},
|
2019-08-10 18:26:28 +00:00
|
|
|
alias: {
|
2019-12-29 20:39:48 +00:00
|
|
|
locale: 'moment/locale',
|
|
|
|
},
|
2019-03-21 01:22:31 +00:00
|
|
|
plugins: [
|
|
|
|
EnvPlugin({ NODE_ENV: isProduction ? 'production' : 'development' }),
|
|
|
|
CSSPlugin(),
|
|
|
|
WebIndexPlugin({
|
|
|
|
title: 'Inferno Typescript FuseBox Example',
|
|
|
|
template: 'src/index.html',
|
2019-12-29 20:39:48 +00:00
|
|
|
path: isProduction ? '/static' : '/',
|
2019-03-21 01:22:31 +00:00
|
|
|
}),
|
|
|
|
isProduction &&
|
2019-12-29 20:39:48 +00:00
|
|
|
QuantumPlugin({
|
|
|
|
bakeApiIntoBundle: 'app',
|
|
|
|
treeshake: true,
|
|
|
|
uglify: true,
|
|
|
|
}),
|
2020-08-11 21:09:41 +00:00
|
|
|
BannerPlugin(libreJsLicense),
|
2019-03-21 01:22:31 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
app = fuse.bundle('app').instructions('>index.tsx');
|
|
|
|
});
|
|
|
|
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
|
|
|
|
Sparky.task('env', _ => (isProduction = true));
|
2019-12-29 20:39:48 +00:00
|
|
|
Sparky.task('copy-assets', () =>
|
|
|
|
Sparky.src('assets/**/**.*').dest(isProduction ? 'dist/' : 'dist/static')
|
|
|
|
);
|
2019-04-09 06:47:08 +00:00
|
|
|
Sparky.task('dev', ['clean', 'config', 'copy-assets'], _ => {
|
2020-07-11 23:03:23 +00:00
|
|
|
fuse.dev({
|
|
|
|
fallback: 'index.html',
|
|
|
|
});
|
2019-03-21 01:22:31 +00:00
|
|
|
app.hmr().watch();
|
|
|
|
return fuse.run();
|
|
|
|
});
|
2019-04-09 06:47:08 +00:00
|
|
|
Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => {
|
2019-03-21 01:22:31 +00:00
|
|
|
return fuse.run();
|
|
|
|
});
|