2019-12-29 16:06:04 -05:00
|
|
|
const {
|
2019-03-20 21:22:31 -04:00
|
|
|
FuseBox,
|
|
|
|
Sparky,
|
|
|
|
EnvPlugin,
|
|
|
|
CSSPlugin,
|
|
|
|
WebIndexPlugin,
|
2019-12-29 15:39:48 -05:00
|
|
|
QuantumPlugin,
|
2019-12-29 16:06:04 -05:00
|
|
|
} = require('fuse-box');
|
2019-03-20 21:22:31 -04:00
|
|
|
// const transformInferno = require('../../dist').default
|
|
|
|
const transformInferno = require('ts-transform-inferno').default;
|
|
|
|
const transformClasscat = require('ts-transform-classcat').default;
|
|
|
|
let fuse, app;
|
|
|
|
let isProduction = false;
|
2019-04-10 14:10:57 -04:00
|
|
|
// var setVersion = require('./set_version.js').setVersion;
|
2019-03-20 21:22:31 -04: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 14:26:28 -04:00
|
|
|
alias: {
|
2019-12-29 15:39:48 -05:00
|
|
|
locale: 'moment/locale',
|
|
|
|
},
|
2019-03-20 21:22:31 -04:00
|
|
|
plugins: [
|
|
|
|
EnvPlugin({ NODE_ENV: isProduction ? 'production' : 'development' }),
|
|
|
|
CSSPlugin(),
|
|
|
|
WebIndexPlugin({
|
|
|
|
title: 'Inferno Typescript FuseBox Example',
|
|
|
|
template: 'src/index.html',
|
2019-12-29 15:39:48 -05:00
|
|
|
path: isProduction ? '/static' : '/',
|
2019-03-20 21:22:31 -04:00
|
|
|
}),
|
|
|
|
isProduction &&
|
2019-12-29 15:39:48 -05:00
|
|
|
QuantumPlugin({
|
|
|
|
bakeApiIntoBundle: 'app',
|
|
|
|
treeshake: true,
|
|
|
|
uglify: true,
|
|
|
|
}),
|
2019-03-20 21:22:31 -04:00
|
|
|
],
|
|
|
|
});
|
|
|
|
app = fuse.bundle('app').instructions('>index.tsx');
|
|
|
|
});
|
2019-04-10 14:10:57 -04:00
|
|
|
// Sparky.task('version', _ => setVersion());
|
2019-03-20 21:22:31 -04:00
|
|
|
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
|
|
|
|
Sparky.task('env', _ => (isProduction = true));
|
2019-12-29 15:39:48 -05:00
|
|
|
Sparky.task('copy-assets', () =>
|
|
|
|
Sparky.src('assets/**/**.*').dest(isProduction ? 'dist/' : 'dist/static')
|
|
|
|
);
|
2019-04-09 02:47:08 -04:00
|
|
|
Sparky.task('dev', ['clean', 'config', 'copy-assets'], _ => {
|
2019-03-20 21:22:31 -04:00
|
|
|
fuse.dev();
|
|
|
|
app.hmr().watch();
|
|
|
|
return fuse.run();
|
|
|
|
});
|
2019-04-09 02:47:08 -04:00
|
|
|
Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => {
|
2019-03-20 21:22:31 -04:00
|
|
|
// fuse.dev({ reload: true }); // remove after demo
|
|
|
|
return fuse.run();
|
|
|
|
});
|