2016-08-22 15:29:35 +02:00
|
|
|
/*
|
|
|
|
* SonarQube
|
2022-01-28 11:50:57 +01:00
|
|
|
* Copyright (C) 2009-2022 SonarSource SA
|
2018-03-21 17:33:08 +01:00
|
|
|
* mailto:info AT sonarsource DOT com
|
2016-08-22 15:29:35 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2017-06-14 11:10:48 +02:00
|
|
|
/* eslint-disable no-console*/
|
2016-08-22 15:29:35 +02:00
|
|
|
process.env.NODE_ENV = 'production';
|
|
|
|
|
2021-09-17 16:29:12 +02:00
|
|
|
const fs = require('fs-extra');
|
|
|
|
const esbuild = require('esbuild');
|
2017-06-14 11:10:48 +02:00
|
|
|
const chalk = require('chalk');
|
2021-09-17 16:29:12 +02:00
|
|
|
const { performance } = require('perf_hooks');
|
|
|
|
const paths = require('../config/paths');
|
|
|
|
|
|
|
|
const getConfig = require('../config/esbuild-config');
|
2016-08-22 15:29:35 +02:00
|
|
|
|
2019-03-27 16:06:20 +01:00
|
|
|
const release = process.argv.findIndex(val => val === 'release') >= 0;
|
2016-08-22 15:29:35 +02:00
|
|
|
|
2021-09-17 16:29:12 +02:00
|
|
|
function clean() {
|
|
|
|
fs.emptyDirSync(paths.appBuild);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function build() {
|
|
|
|
const start = performance.now();
|
2019-03-27 16:06:20 +01:00
|
|
|
console.log(chalk.cyan.bold(`Creating ${release ? 'optimized' : 'fast'} production build...`));
|
2016-11-28 18:13:00 +01:00
|
|
|
console.log();
|
2016-08-22 15:29:35 +02:00
|
|
|
|
2021-10-05 17:00:10 +02:00
|
|
|
await esbuild.build(getConfig(release)).catch(() => process.exit(1));
|
2021-09-17 16:29:12 +02:00
|
|
|
|
|
|
|
console.log(chalk.green.bold('Compiled successfully!'));
|
|
|
|
console.log(chalk.cyan(Math.round(performance.now() - start), 'ms'));
|
|
|
|
console.log();
|
|
|
|
}
|
2021-05-25 14:13:52 +02:00
|
|
|
|
2021-09-17 16:29:12 +02:00
|
|
|
function copyAssets() {
|
|
|
|
fs.copySync(paths.appPublic, paths.appBuild);
|
|
|
|
fs.copySync(paths.docImages, paths.appBuild + '/images/embed-doc/images');
|
2016-11-28 18:13:00 +01:00
|
|
|
}
|
|
|
|
|
2021-09-17 16:29:12 +02:00
|
|
|
(async () => {
|
|
|
|
clean();
|
|
|
|
await build();
|
|
|
|
copyAssets();
|
|
|
|
})();
|