chore: prevent double bundling

Ensure we build the distribution only once:

* development build with NODE_ENV=development
* production build with NODE_ENV=production
This commit is contained in:
Nico Rehwaldt 2021-11-03 11:40:28 +01:00 committed by fake-join[bot]
parent 4dc7122983
commit 732aae361e
2 changed files with 12 additions and 21 deletions

View File

@ -45,7 +45,7 @@ const configs = distros.reduce(function(configs, distro) {
}, },
plugins: pgl([ plugins: pgl([
banner(output) banner(output)
]) ], 'development')
}, },
{ {
input: `./lib/${input}.js`, input: `./lib/${input}.js`,
@ -61,7 +61,7 @@ const configs = distros.reduce(function(configs, distro) {
comments: /license|@preserve/ comments: /license|@preserve/
} }
}) })
]) ], 'production')
} }
]; ];
}, []); }, []);
@ -92,10 +92,10 @@ function banner(bundleName, minified) {
}); });
} }
function pgl(plugins=[]) { function pgl(plugins=[], env='production') {
return [ return [
replace({ replace({
'process.env.NODE_ENV': JSON.stringify('production') 'process.env.NODE_ENV': JSON.stringify(env)
}), }),
nodeResolve({ nodeResolve({
mainFields: [ mainFields: [

View File

@ -33,23 +33,14 @@ cp('./assets/bpmn-js.css', dest + '/assets');
console.log('building pre-packaged distributions'); console.log('building pre-packaged distributions');
var NODE_ENV = process.env.NODE_ENV; try {
exec('rollup', [ '-c' ], {
stdio: 'inherit'
});
} catch (e) {
console.error('failed to build pre-package distributions', e);
[ 'production', 'development' ].forEach(function(env) { process.exit(1);
}
try {
process.env.NODE_ENV = env;
exec('rollup', [ '-c' ], {
stdio: 'inherit'
});
} catch (e) {
console.error('failed to build pre-package distributions', e);
process.exit(1);
}
process.env.NODE_ENV = NODE_ENV;
});
console.log('done.'); console.log('done.');