How to use the fuse-box.ReplacePlugin 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 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',
			'inferno-create-class': '~/packages/inferno-create-class/dist-es',
			'inferno-create-element': '~/packages/inferno-create-element/dist-es',
			'inferno-shared': '~/packages/inferno-shared/dist-es',
			'inferno-hyperscript': '~/packages/inferno-hyperscript/dist-es',
github skellock / typescript-with-electron-react-kit / fuse.ts View on Github external
tsConfig: "tsconfig.json",
  })

  // start the hot reload server
  if (!isProduction) {
    fuse.dev({ port: DEV_PORT, httpServer: false })
  }

  // bundle the electron main code
  const mainBundle = fuse
    .bundle("main")
    .target("server")
    .instructions("> [app/main.ts]")
    // inject in some configuration
    .plugin(
      ReplacePlugin({
        "process.env.HOMEPAGE": pjson.homepage ? `"${pjson.homepage}"` : "null",
      }),
    )

  // and watch unless we're bundling for production
  if (!isProduction) {
    mainBundle.watch()
  }

  // bundle the electron renderer code
  const rendererBundle = fuse
    .bundle("renderer")
    .instructions("> [app/index.tsx] +fuse-box-css")
    .plugin(CSSPlugin())
    .plugin(CopyPlugin({ useDefault: false, files: ASSETS, dest: "assets", resolve: "assets/" }))
github bkniffler / debe / example / todo / fuse.ts View on Github external
fuse.dev({
      fallback: '../src/index.html',
      port: DEV_PORT
    });
  }

  // bundle the electron renderer code
  const browser = fuse
    .bundle('browser')
    .target('browser@esnext')
    .instructions('> example/todo/src/index.tsx')
    .plugin(JSONPlugin())
    .plugin(WebIndexPlugin({ template: './src/index.html' }))
    .plugin(CSSPlugin({ inject: true }))
    .plugin(
      ReplacePlugin({
        'process.env.NODE_ENV': `${process.env.NODE_ENV}`
      })
    );

  const server = fuse
    .bundle('server')
    .target('server@esnext')
    .instructions('> example/todo/server/index.ts -better-sqlite3');

  if (!isProduction) {
    server.watch(
      p =>
        p.indexOf(`/debe/src/`) !== -1 ||
        p.indexOf(resolve(__dirname, 'server')) === 0
    );
    browser.watch(
github patrickmichalina / fusing-angular / tools / runner / bundle.ts View on Github external
}

  const webIndexPlugin = WebIndexPlugin({
    engine: 'pug',
    path: `${opts.jsOutputDir}`,
    template: `${opts.srcRoot}/${opts.browser.rootDir}/${opts.browser.indexTemplatePath}`,
    target: '../index.html',
    scriptAttributes: 'defer',
    locals: {
      csp: opts.enableAotCompilaton
        ? `script-src 'self'; object-src 'self'`
        : `script-src 'self' 'unsafe-eval'; object-src 'self'`
    }
  })

  const replacePlugin = ReplacePlugin({ "__APPVERSION__": pkg.version })

  const httpServer = opts.serve && !opts.universal.enabled
  const UNIVERSAL_PORT = 4200
  const port = httpServer ? UNIVERSAL_PORT : 4201

  const browserEntry = opts.enableAotCompilaton
    ? `${opts.browser.rootDir}/${opts.browser.bundle.aotInputPath}`
    : `${opts.browser.rootDir}/${opts.browser.bundle.inputPath}`

  const electronBrowserEntry = opts.enableAotCompilaton
    ? `${opts.electron.rootDir}/${opts.electron.bundle.aotInputPath}`
    : `${opts.electron.rootDir}/${opts.electron.bundle.inputPath}`

  const browser = FuseBox.init({
    ...shared,
    hash: true,
github fliphub / fliphub / packages / fliphub / src / presets / PresetDefineEnv.js View on Github external
toFuseBox() {
    const {FuseBox, ReplacePlugin} = require('fuse-box')

    return {
      pluginIndex: 90,
      plugins: [
        ReplacePlugin({'process.env.NODE_ENV': JSON.stringify('production')}),
      ],
    }
  }
  toWebpack() {