How to use the fuse-box.FuseBox.init function in fuse-box

To help you get started, we’ve selected a few fuse-box examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github patrickmichalina / fusing-angular-cli / fuse.ts View on Github external
import { FuseBox, QuantumPlugin, JSONPlugin, RawPlugin } from 'fuse-box'
import { src, task } from 'fuse-box/sparky'
import { resolve } from 'path'
import { argv } from 'yargs'
import { execSync } from 'child_process'
import shabang from './tools/scripts/fuse-shebang'
// import { unlinkSync } from 'fs'

const appName = 'fng'
const outputDir = '.build'
const homeDir = './'
const outputPath = `${outputDir}/${appName}`
const absOutputPath = resolve(outputPath)
const isProdBuild = argv.build

const fuseConfig = FuseBox.init({
  log: false,
  cache: !isProdBuild,
  target: 'server@es5',
  homeDir,
  output: `${outputDir}/$name`,
  globals: {
    default: '*'
  },
  package: {
    name: 'default',
    main: outputPath
  },
  plugins: [
    JSONPlugin(),
    RawPlugin(['.txt']),
    isProdBuild &&
github infernojs / inferno / flip.js View on Github external
function infernoFuse(name) {
	const { FuseBox, UglifyJSPlugin, ReplacePlugin } = require('fuse-box');
	const isProd = process.argv.includes('--production');
	const fuse = FuseBox.init({
		src: 'packages',
		outFile: 'inferno.fused.js',
		plugins: [
			ReplacePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
			isProd && UglifyJSPlugin()
		],
		rollup: {
			bundle: {
				moduleName: 'Inferno'
			},
			entry: 'packages/inferno/src/index.js'
		},
		debug: true,
		alias: { // this can be automatically assigned
			'inferno-compat': '~/packages/inferno-compat',
			'inferno-component': '~/packages/inferno-component/dist-es',
github WorkSight / rewire / fuse-build.js View on Github external
Sparky.task('config', (context) => {
  fuse = FuseBox.init({
    globals:              { default: '*' }, // we need to expore index in our bundles
    target:               context.target,
    homeDir:              context.home,
    useTypescriptCompiler:true,
    cache:                false,
    hash:                 false,
    // sourceMaps:           {[context.bundleName]: true},
    tsConfig:             'tsconfig-build.json',
    output:               `${context.home}/$name.js`,
    plugins:                         [
      JSONPlugin(),
      EnvPlugin({ NODE_ENV: context.isProduction ? 'production' : 'development' }),
      CSSPlugin(),
      [SassPlugin(), CSSPlugin()],
      ImageBase64Plugin({ useDefault: true }),
      context.isProduction && QuantumPlugin({
github basarat / takeme / fuse.js View on Github external
const app = express();
  app.use('/', (req, res) => {
    if ( req.path.indexOf('app.js')!==-1 ) {
      res.sendFile(__dirname + '/demo/app.js');
    }
    else {
      res.sendFile(__dirname + '/demo/index.html');
    }
  });
  app.listen(8080, () => console.log('Example app listening on port 8080!'));
}
else {
  box.bundle('>demo/app.tsx');

  /** Also bundle for server side demo */
  FuseBox
  .init({
    homeDir: "src",
    sourceMap: {
      bundleReference: "sourcemaps.js.map",
      outFile: "demo/awesome/sourcemaps.js.map",
    },
    outFile: "demo/awesome/appServer.js",
    plugins: [
      fsbx.EnvPlugin({ NODE_ENV: process.argv[2] }),
      !process.argv.includes('client') 
        && !process.argv.includes('server') 
        && fsbx.UglifyJSPlugin()
    ]
  }).bundle('>demo/appServer.tsx');
}
github patrickmichalina / fusing-angular-v1-archived / fuse.ts View on Github external
Sparky.task('build.universal', () => {
  const fuseApp = FuseBox.init(appOptions as any)
  const fuseServer = FuseBox.init(serverOptions as any)
  const path = isAot ? 'client/.aot/src/client/app' : 'client/app'
  const serverBundle = fuseServer
    .bundle('server')
    .instructions(serverBundleInstructions)
  const vendorBundle = fuseApp
    .bundle(`${vendorBundleName}`)
    .instructions(vendorBundleInstructions)

  const addInstructs = isAot
    ? `${appBundleInstructions}`
    : `${appBundleInstructions} + [${path}/**/!(*.spec|*.e2e-spec|*.ngsummary|*.snap).*(!scss)]`

  const appBundle = fuseApp
    .bundle(appBundleName)
    .splitConfig({ dest: 'js/modules' })
    .instructions(addInstructs)
github projectSHAI / GOATstack / fuse.js View on Github external
"use strict";

const { FuseBox, ReplacePlugin, TypeScriptHelpers, JSONPlugin, UglifyJSPlugin } = require('fuse-box');
const path = require('path');

const isDevelopment = process.argv.indexOf("--dev") > -1
const isTest = process.argv.indexOf("--test") > -1;
const isProduction = process.argv.indexOf("--prod") > -1;

const env = isDevelopment ? 'development' : isTest ? 'test' :
	isProduction ? 'production' : 'no-env';

const fuseBox = FuseBox.init({
    homeDir: `./`,
    outFile: `dist/index.js`,
    plugins: [
        ReplacePlugin({ "process.env.NODE_ENV": JSON.stringify(env) }),
        TypeScriptHelpers(),
        JSONPlugin(),
        isProduction && UglifyJSPlugin()
    ]
}).bundle('>[server/server.ts]');
github patrickmichalina / fusing-angular / tools / runner / bundle.ts View on Github external
NgPolyfillPlugin({ isAot: opts.enableAotCompilaton }),
      NgTemplatePlugin({ enabled: !opts.enableAotCompilaton }),
      NgAotFactoryPlugin({ enabled: opts.enableAotCompilaton }),
      NgCompilerPlugin({ enabled: opts.enableAotCompilaton }),
      opts.optimizations.enabled && QuantumPlugin({
        uglify: opts.optimizations.minify,
        treeshake: opts.optimizations.treeshake,
        bakeApiIntoBundle: opts.vendorBundleName,
        processPolyfill: opts.enableAotCompilaton
      }) as any,
      webIndexPlugin,
      replacePlugin
    ]
  })

  const electronBrowser = FuseBox.init({
    ...shared,
    hash: true,
    target: 'electron',
    sourceMaps: false,
    ignoreModules: opts.browser.bundle.ignoredModules,
    output: `${opts.outputDirectory}/${'electron'}/public/js/$name.js`,
    plugins: [
      NgProdPlugin({ enabled: opts.optimizations.enabled }),
      NgPolyfillPlugin({ isAot: opts.enableAotCompilaton }),
      NgTemplatePlugin({ enabled: !opts.enableAotCompilaton }),
      NgAotFactoryPlugin({ enabled: opts.enableAotCompilaton }),
      NgCompilerPlugin({ enabled: opts.enableAotCompilaton, tsconfig: 'tsconfig.electron.aot.json' }),
      opts.optimizations.enabled && QuantumPlugin({
        uglify: opts.optimizations.minify,
        treeshake: opts.optimizations.treeshake,
        bakeApiIntoBundle: opts.vendorBundleName,
github patrickmichalina / fusing-angular-cli / src / commands / serve.ts View on Github external
const serverOutput = resolve(config.fusebox.server.outputDir)
      const browserOutput = resolve(config.fusebox.browser.outputDir)
      const modulesFolder = resolve(process.cwd(), 'node_modules')
      const watchDir = resolve(`${homeDir}/src/**`)
      const appName =
        (config.favicon &&
          config.favicon.config &&
          config.favicon.config.appName) ||
        'FUSING ANGULAR'
      const browserModule = isAotBuild
        ? config.fusebox.browser.aotBrowserModule
        : config.fusebox.browser.browserModule

      isAotBuild && ngc(['-p', resolve('tsconfig.aot.json')])

      const fuseBrowser = FuseBox.init({
        log,
        modulesFolder,
        homeDir,
        cache,
        hash: isProdBuild,
        output: `${browserOutput}/$name.js`,
        target: 'browser@es5',
        useTypescriptCompiler: true,
        plugins: [
          isAotBuild && NgAotFactoryPlugin(),
          isAotBuild &&
            NgAotRelativePlugin({
              '"./not-found.component"': 'not-found/not-found.component',
              '"../response/browser.response.service"':
                'response/browser.response.service'
            }),
github patrickmichalina / fusebox-angular-universal-starter / fuse.js View on Github external
Sparky.task("build.prod.min.universal", ["build.prod"], () => {
  const fuse = FuseBox.init(prodOptions);
  fuse.opts.plugins = [...fuse.opts.plugins, UglifyESPlugin()]
  fuse.bundle('js/vendor').instructions(' ~ client/main.ts');
  fuse.bundle("js/app").instructions(" !> [client/main.ts]");
  fuse.bundle("server").instructions(" > [server/server.ts]");
  fuse.run()
})
github wexond / wexond-ui / fuse.js View on Github external
async init() {
    const {
      name,
      target,
      instructions,
      watch,
      watchFilter,
      runWhenCompleted,
      devServerOptions,
    } = this.config;
    const fuse = FuseBox.init(this.fuseConfig);
    const app = fuse.bundle(name).instructions(instructions);

    if (!production) {
      app.watch(watch, watchFilter);

      if (target !== 'server') {
        fuse.dev(devServerOptions);
        app.hmr();
      } else if (runWhenCompleted) {
        app.completed(proc => proc.start());
      }
    }

    return await fuse.run();
  }
}