1 import { CSSPlugin, FuseBox, FuseBoxOptions, Sparky } from 'fuse-box';
2 import path = require('path');
3 import TsTransformClasscat from 'ts-transform-classcat';
4 import TsTransformInferno from 'ts-transform-inferno';
6 * Some of FuseBoxOptions overrides by ts config (module, target, etc)
7 * https://fuse-box.org/page/working-with-targets
10 const fuseOptions: FuseBoxOptions = {
12 output: 'dist/$name.js',
13 sourceMaps: { inline: false, vendor: false },
15 * Custom TypeScript Transformers (compile Inferno tsx to ts)
18 before: [TsTransformClasscat(), TsTransformInferno()],
21 const fuseClientOptions: FuseBoxOptions = {
25 * https://fuse-box.org/page/css-resource-plugin
26 * Compile Sass {SassPlugin()}
27 * Make .css files modules-like (allow import them like modules) {CSSModules}
28 * Make .css files modules like and allow import it from node_modules too {CSSResourcePlugin}
29 * Use them all and bundle with {CSSPlugin}
34 const fuseServerOptions: FuseBoxOptions = {
38 Sparky.task('clean', () => {
39 /**Clean distribute (dist) folder */
40 Sparky.src('dist/').clean('dist/');
42 Sparky.task('config', () => {
43 fuse = FuseBox.init(fuseOptions);
46 Sparky.task('test', ['&clean', '&config'], () => {
47 fuse.bundle('client/bundle').test('[**/**.test.tsx]', null);
49 Sparky.task('client', () => {
50 fuse.opts = fuseClientOptions;
52 .bundle('client/bundle')
53 .target('browser@esnext')
56 .instructions('> client/index.tsx');
58 Sparky.task('copy-assets', () =>
59 Sparky.src('**/**.*', { base: 'src/assets' }).dest('dist/assets')
61 Sparky.task('server', () => {
62 /**Workaround. Should be fixed */
63 fuse.opts = fuseServerOptions;
65 .bundle('server/bundle')
67 .target('server@esnext')
68 .instructions('> [server/index.tsx]')
71 // tslint:disable-next-line:no-shadowed-variable
72 close: ({ FuseBox }) => FuseBox.import(FuseBox.mainFile).shutdown(),
78 ['&clean', '&config', '&client', '&server', '©-assets'],