Skip to content

Commit

Permalink
fuse 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nchanged committed Jan 3, 2018
1 parent 5cf8f30 commit 76e22e0
Show file tree
Hide file tree
Showing 3 changed files with 3,674 additions and 50 deletions.
110 changes: 60 additions & 50 deletions fuse.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,74 @@
const {
BabelPlugin,
FuseBox,
SassPlugin,
CSSPlugin,
Sparky,
WebIndexPlugin,
TypeScriptHelpers,
JSONPlugin,
HTMLPlugin,
Sparky,
QuantumPlugin,
} = require('fuse-box');
SassPlugin,
JSONPlugin,
CSSPlugin,
QuantumPlugin
} = require("fuse-box");
const { src, task, watch, context, fuse } = require("fuse-box/sparky");

let fuse, app, vendor, isProduction;

Sparky.task("config", () => {
fuse = FuseBox.init({
homeDir: `src/`,
output: `dist/$name.js`,
hash: isProduction,
target: "browser",
plugins: [
WebIndexPlugin({
title: 'FuseBox + Angular',
template: 'src/index.html',
}), [
SassPlugin({
outputStyle: 'compressed',
context(class {
getConfig() {
return FuseBox.init({
homeDir: "src",
output: "dist/$name.js",
target: "browser@es5",
hash: this.isProduction,
plugins: [
WebIndexPlugin({
title: 'FuseBox + Angular',
template: 'src/index.html',
}), [
SassPlugin({
outputStyle: 'compressed',
}),
CSSPlugin(),
],
JSONPlugin(),
HTMLPlugin({
useDefault: false,
}),
CSSPlugin(),
],
JSONPlugin(),
HTMLPlugin({
useDefault: false,
}),
// http://fuse-box.org/page/quantum
isProduction && QuantumPlugin({
uglify: true,
hoisting: { names: ["tslib_1"] },
treeshake: true
}),
],
});
this.isProduction && QuantumPlugin({
bakeApiIntoBundle: "app",
uglify: true
})
]
})
}
createBundle(fuse) {
const vendor = fuse.bundle("vendor").instructions("~ main.ts");
if (!this.isProduction) {
vendor.watch()
vendor.hmr()
}

vendor = fuse.bundle('vendor').instructions(' ~ main.ts');
app = fuse.bundle('app')
.sourceMaps(!isProduction)
.instructions(' !> [main.ts]');
const app = fuse.bundle("app");
if (!this.isProduction) {
app.watch()
app.hmr()
}
app.instructions(">[main.ts]");
return app;
}
});

Sparky.task("default", ["clean", "config"], () => {
task("clean", () => src("dist").clean("dist").exec())

task("default", ["clean"], async context => {
const fuse = context.getConfig();
fuse.dev();
// add dev instructions
app.watch().hmr()
return fuse.run();
context.createBundle(fuse);
await fuse.run();
});

Sparky.task("clean", () => Sparky.src("dist/").clean("dist/"));
Sparky.task("prod-env", ["clean"], () => { isProduction = true })
Sparky.task("dist", ["prod-env", "config"], () => {
// comment out to prevent dev server from running (left for the demo)
fuse.dev();
return fuse.run();
task("dist", ["clean"], async context => {
context.isProduction = true;
const fuse = context.getConfig();
fuse.dev(); // remove it later
context.createBundle(fuse);
await fuse.run();
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@covalent/http": "^1.0.0-beta.4",
"angular-in-memory-web-api": "0.3.2",
"core-js": "2.4.1",
"fuse-box": "^3.0.0-next.48",
"lodash": "4.17.4",
"rxjs": "5.4.0",
"zone.js": "0.8.11"
Expand Down
Loading

0 comments on commit 76e22e0

Please sign in to comment.