2018-10-22 01:39:03 +00:00
|
|
|
const {
|
|
|
|
FuseBox,
|
|
|
|
Sparky,
|
|
|
|
EnvPlugin,
|
|
|
|
CSSPlugin,
|
|
|
|
WebIndexPlugin,
|
2018-12-02 09:16:31 +00:00
|
|
|
QuantumPlugin
|
2018-10-22 01:39:03 +00:00
|
|
|
} = require('fuse-box');
|
|
|
|
// 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;
|
2018-12-25 23:19:16 +00:00
|
|
|
var setEnv = require('./set_env.js').setEnv;
|
2018-10-22 01:39:03 +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()],
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
EnvPlugin({ NODE_ENV: isProduction ? 'production' : 'development' }),
|
|
|
|
CSSPlugin(),
|
|
|
|
WebIndexPlugin({
|
|
|
|
title: 'Inferno Typescript FuseBox Example',
|
|
|
|
template: 'src/index.html',
|
2018-11-27 21:29:56 +00:00
|
|
|
path: isProduction ? "/static" : "/"
|
2018-10-22 01:39:03 +00:00
|
|
|
}),
|
|
|
|
isProduction &&
|
|
|
|
QuantumPlugin({
|
|
|
|
bakeApiIntoBundle: 'app',
|
|
|
|
treeshake: true,
|
|
|
|
uglify: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|
|
|
|
app = fuse.bundle('app').instructions('>index.tsx');
|
|
|
|
});
|
|
|
|
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
|
|
|
|
Sparky.task('env', _ => (isProduction = true));
|
2018-12-25 23:19:16 +00:00
|
|
|
Sparky.task('set_env', _ => {
|
|
|
|
setEnv();
|
|
|
|
});
|
2018-12-02 09:16:31 +00:00
|
|
|
Sparky.task('copy-assets', () => Sparky.src('assets/*.ico').dest('dist/'));
|
2018-12-25 23:19:16 +00:00
|
|
|
Sparky.task('dev', ['clean', 'set_env', 'config', 'copy-assets'], _ => {
|
2018-10-22 01:39:03 +00:00
|
|
|
fuse.dev();
|
|
|
|
app.hmr().watch();
|
|
|
|
return fuse.run();
|
|
|
|
});
|
2018-12-25 23:19:16 +00:00
|
|
|
Sparky.task('prod', ['clean', 'set_env', 'env', 'config', 'copy-assets'], _ => {
|
2018-10-22 01:39:03 +00:00
|
|
|
// fuse.dev({ reload: true }); // remove after demo
|
|
|
|
return fuse.run();
|
|
|
|
});
|