]> Untitled Git - lemmy.git/blob - ui/fuse.js
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / ui / fuse.js
1 const {
2   FuseBox,
3   Sparky,
4   EnvPlugin,
5   CSSPlugin,
6   WebIndexPlugin,
7   QuantumPlugin,
8 } = require('fuse-box');
9 const transformInferno = require('ts-transform-inferno').default;
10 const transformClasscat = require('ts-transform-classcat').default;
11 let fuse, app;
12 let isProduction = false;
13
14 Sparky.task('config', _ => {
15   fuse = new FuseBox({
16     homeDir: 'src',
17     hash: isProduction,
18     output: 'dist/$name.js',
19     experimentalFeatures: true,
20     cache: !isProduction,
21     sourceMaps: !isProduction,
22     transformers: {
23       before: [transformClasscat(), transformInferno()],
24     },
25     alias: {
26       locale: 'moment/locale',
27     },
28     plugins: [
29       EnvPlugin({ NODE_ENV: isProduction ? 'production' : 'development' }),
30       CSSPlugin(),
31       WebIndexPlugin({
32         title: 'Inferno Typescript FuseBox Example',
33         template: 'src/index.html',
34         path: isProduction ? '/static' : '/',
35       }),
36       isProduction &&
37         QuantumPlugin({
38           bakeApiIntoBundle: 'app',
39           treeshake: true,
40           uglify: true,
41         }),
42     ],
43   });
44   app = fuse.bundle('app').instructions('>index.tsx');
45 });
46 Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
47 Sparky.task('env', _ => (isProduction = true));
48 Sparky.task('copy-assets', () =>
49   Sparky.src('assets/**/**.*').dest(isProduction ? 'dist/' : 'dist/static')
50 );
51 Sparky.task('dev', ['clean', 'config', 'copy-assets'], _ => {
52   fuse.dev({
53     fallback: 'index.html',
54   });
55   app.hmr().watch();
56   return fuse.run();
57 });
58 Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => {
59   return fuse.run();
60 });