Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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',
'inferno-mobx': '~/packages/inferno-mobx/dist-es',
}),
NgPolyfillPlugin({
isServer: true,
fileTest: 'server.angular.module.ts'
})
]
})
// tslint:disable-next-line:no-let
let prevServerProcess: FuseProcess
const fuseSw = FuseBox.init({
homeDir: resolve('node_modules/@angular/service-worker'),
output: `${browserOutput}/$name.js`,
target: 'browser@es5',
plugins: [isProdBuild && UglifyJSPlugin(), CompressionPlugin()] as any
})
fuseSw.bundle('ngsw-worker').instructions(' > [ngsw-worker.js]')
// tslint:disable:no-if-statement
const vendor = fuseBrowser.bundle('vendor')
if (!buildOnly) vendor.watch(watchDir)
vendor.instructions(` ~ ${browserModule}`).completed(fn => {
isServiceWorkerEnabled &&
execSync(
`node_modules/.bin/ngsw-config .dist/public src/app/ngsw.json`
)
const serverBundle = fuseServer
.bundle('server')
.instructions(` > [${config.fusebox.server.serverModule}]`)
if (!buildOnly) {
const fsbx = require('fuse-box')
// utils
const isDevelopment = process.env.NODE_ENV === 'development'
const name = isDevelopment ? 'build/bundle' : 'build/dist.min'
// plugins
const plugins = [fsbx.BabelPlugin()]
if (!isDevelopment) {
plugins.push(fsbx.UglifyJSPlugin())
}
// config
const fuse = fsbx.FuseBox.init({
homeDir: 'src',
output: 'static/$name.js',
debug: isDevelopment,
log: isDevelopment,
sourceMaps: isDevelopment,
plugins,
})
// start dev server
if (isDevelopment) {
toFuseBox(config) {
const {BabelPlugin} = require('fsbx')
const {UglifyJSPlugin} = require('fuse-box')
return {
pluginIndex: 100,
plugins: [[BabelPlugin({config: this.babelArgs}), UglifyJSPlugin()]],
// plugins: [BabelPlugin()],
}
}
}
let run = (production) => {
const fuse = FuseBox.init({
target: "browser@es6",
homeDir: 'src',
output: 'dist/$name.js',
runAllMatchedPlugins: true,
plugins: [
production && UglifyJSPlugin(),
production && QuantumPlugin(),
EnvPlugin({
devMode: !production
}),
HTMLPlugin(),
WebIndexPlugin({
template: './index.html'
})
]
});
fuse.bundle("vendor")
.cache(true)
.instructions('~ startup.ts');
if (!production) {
fuse.bundle("app")
.instructions(" > [startup.ts]")
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]');
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');
}
toFuseBox() {
const {UglifyJSPlugin} = require('fuse-box')
return {plugins: [UglifyJSPlugin()]}
}
}