Пример #1
0
Sparky.task("build", () => {
    const fuse = FuseBox.init({
        homeDir: "src",
        output: "dist/static/$name.js",
        hash: production,
        target: "electron",
        experimentalFeatures: true,
        cache: !production,
        plugins: [
            EnvPlugin({ NODE_ENV: production ? "production" : "development" }),
            [SassPlugin(), CSSPlugin()],
            WebIndexPlugin({
                title: "FuseBox electron demo",
                template: "src/renderer/index.html",
                path: production ? "." : "/static/"
            }),
            production && QuantumPlugin({
                bakeApiIntoBundle : 'main',
                target : 'electron',
                treeshake: true,
                removeExportsInterop: false,
                uglify: true
            })
        ]
    });
    if (!production) {
        // Configure development server
        fuse.dev({ root: false }, server => {
            const dist = path.join(__dirname, "dist");
            const serverApp = server.httpServer.app;
            serverApp.use("/static/", express.static(path.join(dist, 'static')));
            serverApp.get("*", function(req, res) {
                res.sendFile(path.join(dist, "static/index.html"));
            });
        })
    }

    const renderer = fuse.bundle("renderer")
        .instructions('> [renderer/index.ts] + fuse-box-css')

    const main = fuse.bundle("main")
            .target("electron")
            .instructions(" > [main/electron.ts]"); // it's import to isolate like this []

    if (!production) { 
        let mainProc;
        renderer.hmr().watch('renderer/**')
        main.watch('main/**').completed(() => {
            if (mainProc) {
                treeKill(mainProc.pid)
            }
            mainProc = spawn('node', [`${ __dirname }/node_modules/electron/cli.js`, __dirname], { stdio: 'inherit' });
        })
    }

    return fuse.run()
});
Пример #2
0
  },
  outFile: './build/bundle.js',
  plugins: [
    fsbx.JSONPlugin(),
    fsbx.BabelPlugin({
      config: {
        sourceMaps: true,
        presets: ['latest'],
        plugins: [
          'transform-react-jsx',
        ],
      }
    }),
    [
      fsbx.SassPlugin({ outputStyle: 'compressed' }),
      fsbx.CSSPlugin({ minify: false }),
    ],
  ],
});

gulp.task('bundle', () => {
  fuseBox.bundle('>index.js')
});

gulp.task('index.html', (done) => {
  gulp.src('./src/index.html')
  .pipe(gulp.dest('./build'))
  .on('end', done);
});

gulp.task('default', ['bundle', 'index.html'], function () {