|
|
@ -0,0 +1,112 @@ |
|
|
|
import { fusebox, sparky, pluginCustomTransform } from 'fuse-box'; |
|
|
|
|
|
|
|
import Inferno from 'ts-transform-inferno'; |
|
|
|
import Classcat from 'ts-transform-classcat'; |
|
|
|
// const transformInferno = require('ts-transform-inferno').default;
|
|
|
|
// const transformClasscat = require('ts-transform-classcat').default;
|
|
|
|
|
|
|
|
// Sparky.task('config', _ => {
|
|
|
|
// fuse = new FuseBox({
|
|
|
|
// homeDir: 'src',
|
|
|
|
// hash: isProduction,
|
|
|
|
// output: 'dist/$name.js',
|
|
|
|
// // experimentalFeatures: true,
|
|
|
|
// cache: !isProduction,
|
|
|
|
// sourceMaps: !isProduction,
|
|
|
|
// transformers: {
|
|
|
|
// before: [transformClasscat(), transformInferno()],
|
|
|
|
// },
|
|
|
|
// alias: {
|
|
|
|
// locale: 'moment/locale',
|
|
|
|
// },
|
|
|
|
// plugins: [
|
|
|
|
// EnvPlugin({ NODE_ENV: isProduction ? 'production' : 'development' }),
|
|
|
|
// CSSPlugin(),
|
|
|
|
// WebIndexPlugin({
|
|
|
|
// title: 'Inferno Typescript FuseBox Example',
|
|
|
|
// template: 'src/index.html',
|
|
|
|
// path: isProduction ? '/static' : '/',
|
|
|
|
// }),
|
|
|
|
// isProduction &&
|
|
|
|
// QuantumPlugin({
|
|
|
|
// bakeApiIntoBundle: 'app',
|
|
|
|
// treeshake: true,
|
|
|
|
// uglify: true,
|
|
|
|
// }),
|
|
|
|
// ],
|
|
|
|
// });
|
|
|
|
// app = fuse.bundle('app').instructions('>index.tsx');
|
|
|
|
// });
|
|
|
|
// // Sparky.task('version', _ => setVersion());
|
|
|
|
// Sparky.task('clean', => Sparky.src('dist/').clean('dist/'));
|
|
|
|
// Sparky.task('env', _ => (isProduction = true));
|
|
|
|
// Sparky.task('copy-assets', () =>
|
|
|
|
// Sparky.src('assets/**/**.*').dest(isProduction ? 'dist/' : 'dist/static')
|
|
|
|
// );
|
|
|
|
// Sparky.task('dev', ['clean', 'config', 'copy-assets'], _ => {
|
|
|
|
// fuse.dev();
|
|
|
|
// app.hmr().watch();
|
|
|
|
// return fuse.run();
|
|
|
|
// });
|
|
|
|
// Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => {
|
|
|
|
// // fuse.dev({ reload: true }); // remove after demo
|
|
|
|
// return fuse.run();
|
|
|
|
// });
|
|
|
|
|
|
|
|
class Context { |
|
|
|
runServer: any; |
|
|
|
getConfig = () => |
|
|
|
fusebox({ |
|
|
|
target: 'browser', |
|
|
|
entry: 'src/index.tsx', |
|
|
|
webIndex: { |
|
|
|
template: 'src/index.html', |
|
|
|
// publicPath: 'static',
|
|
|
|
}, |
|
|
|
cache: true, |
|
|
|
// link: { resourcePublicRoot: '/assets' },
|
|
|
|
// resources: {
|
|
|
|
// resourceFolder: './dist/assets',
|
|
|
|
// resourcePublicRoot: './assets',
|
|
|
|
// },
|
|
|
|
plugins: [ |
|
|
|
pluginCustomTransform({ |
|
|
|
before: [Inferno()], |
|
|
|
}), |
|
|
|
// pluginLink(/\.js/, { useDefault: true }),
|
|
|
|
// pluginLink(/\.css/, { useDefault: true }),
|
|
|
|
], |
|
|
|
|
|
|
|
// dependencies: {
|
|
|
|
// ignoreAllExternal: true,
|
|
|
|
// },
|
|
|
|
devServer: this.runServer, |
|
|
|
}); |
|
|
|
} |
|
|
|
const { task, src } = sparky<Context>(Context); |
|
|
|
|
|
|
|
// task("copy:images", async () => {
|
|
|
|
// await src("./**/*.png", { base: "./src/assets" })
|
|
|
|
// .dest("./dist/")
|
|
|
|
// .exec()
|
|
|
|
// })
|
|
|
|
|
|
|
|
task; |
|
|
|
task('dev', async ctx => { |
|
|
|
ctx.runServer = true; |
|
|
|
const fuse = ctx.getConfig(); |
|
|
|
|
|
|
|
await src('assets/**/**.*') |
|
|
|
.dest('dist/static', '') |
|
|
|
.exec(); |
|
|
|
await fuse.runDev(); |
|
|
|
}); |
|
|
|
|
|
|
|
task('prod', async ctx => { |
|
|
|
ctx.runServer = false; |
|
|
|
const fuse = ctx.getConfig(); |
|
|
|
await fuse.runProd({ |
|
|
|
uglify: false, |
|
|
|
// screwIE: true,
|
|
|
|
}); |
|
|
|
}); |