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,
|
2019-12-29 21:06:04 +00:00
|
|
|
} = require('fuse-box');
|
2019-03-21 01:22:31 +00: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 18:10:57 +00:00
|
|
|
// var setVersion = require('./set_version.js').setVersion;
|
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,
|
|
|
|
}),
|
2019-03-21 01:22:31 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
app = fuse.bundle('app').instructions('>index.tsx');
|
|
|
|
});
|
2019-04-10 18:10:57 +00:00
|
|
|
// Sparky.task('version', _ => setVersion());
|
2019-03-21 01:22:31 +00:00
|
|
|
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'], _ => {
|
2019-03-21 01:22:31 +00:00
|
|
|
fuse.dev();
|
|
|
|
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
|
|
|
// fuse.dev({ reload: true }); // remove after demo
|
|
|
|
return fuse.run();
|
|
|
|
});
|