Created
November 28, 2017 07:35
-
-
Save ccapndave/4fd3661458c84137d83be1b31289b2b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FuseBox, PostCSSPlugin, LESSPlugin, CSSPlugin, QuantumPlugin, Sparky } from "fuse-box"; | |
import { ElmPlugin } from "fuse-box-elm-plugin"; | |
import * as path from "path"; | |
const homeDir = "app"; | |
const destDir = "dist"; | |
Sparky.task("build", () => { | |
console.log(path.resolve(__dirname, "node_modules", "normalize.css")); | |
const fuse = FuseBox.init({ | |
homeDir, | |
output: `${destDir}/$name.js`, | |
plugins: [ | |
// Elm | |
ElmPlugin(), | |
// Less chain | |
[ | |
LESSPlugin(), | |
PostCSSPlugin([require("autoprefixer")({ map: true, browsers: ['last 2 version'] })]), | |
CSSPlugin() | |
]/*, | |
QuantumPlugin({ | |
uglify: true, | |
treeshake: true | |
})*/ | |
], | |
target: "browser", | |
sourceMaps: true, | |
debug: false | |
}); | |
fuse.dev({ httpServer: false }); | |
// Bundle the application | |
fuse.bundle("app") | |
.watch() | |
.instructions("> js/app.ts") | |
.hmr(); | |
fuse.run(); | |
}); | |
Sparky.task("server", () => { | |
const fuse = FuseBox.init({ | |
homeDir, | |
output: `${destDir}/$name.js`, | |
target: "server" | |
}); | |
// Run the development server | |
fuse.bundle("server") | |
.instructions("> [server.js]") | |
.watch("server.js") | |
.completed(proc => { | |
proc.kill(); | |
proc.start(); | |
}); | |
fuse.run(); | |
}); | |
Sparky.task("copy:assets", () => Sparky.watch("./assets/**/*", { base: homeDir }).dest(`./${destDir}`)); | |
Sparky.task("copy:vendor", () => Sparky.watch("./vendor/**/*", { base: homeDir }).dest(`./${destDir}`)); | |
Sparky.task("copy:index", () => Sparky.watch("./index.html", { base: homeDir }).dest(`./${destDir}`)); | |
Sparky.task("copy", ["copy:assets", "copy:vendor", "copy:index"], () => {}); | |
function copyConfig(configFile) { | |
return Sparky | |
.src(configFile, { base: "config/" }) | |
.file("*", file => file.rename("config.json")) | |
.dest(destDir + "/$name"); | |
} | |
Sparky.task("config:dev-online", () => copyConfig('config-dev-online.json')); | |
Sparky.task("dev", ["copy", "build", "server"], () => {}); | |
Sparky.task("dev:online", ["config:dev-online"], () => {}); | |
Sparky.task("default", ["dev"], () => {}); | |
// TODO: B27 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment