diff options
author | Jeremy Davis <jeremy.davis@sonarsource.com> | 2021-09-17 16:29:12 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-09-30 20:03:00 +0000 |
commit | 18582f55e72704e61c331467e90de7b023d0b46c (patch) | |
tree | 98baf9a40895b0fedb19f5d739e55ea2592f385b /server/sonar-web/scripts/build.js | |
parent | 62b21006de51a5b15819e70f4a0943ab983d2b68 (diff) | |
download | sonarqube-18582f55e72704e61c331467e90de7b023d0b46c.tar.gz sonarqube-18582f55e72704e61c331467e90de7b023d0b46c.zip |
[NO-JIRA] use esbuild for sonar-web
Diffstat (limited to 'server/sonar-web/scripts/build.js')
-rw-r--r-- | server/sonar-web/scripts/build.js | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/server/sonar-web/scripts/build.js b/server/sonar-web/scripts/build.js index 8d005375e5c..42d461449f9 100644 --- a/server/sonar-web/scripts/build.js +++ b/server/sonar-web/scripts/build.js @@ -20,30 +20,39 @@ /* eslint-disable no-console*/ process.env.NODE_ENV = 'production'; +const fs = require('fs-extra'); +const esbuild = require('esbuild'); const chalk = require('chalk'); -const webpack = require('webpack'); -const reportBuildStats = require('./utils/reportBuildStats'); -const getConfigs = require('../config/webpack.config'); +const { performance } = require('perf_hooks'); +const paths = require('../config/paths'); + +const getConfig = require('../config/esbuild-config'); const release = process.argv.findIndex(val => val === 'release') >= 0; -const configs = getConfigs({ production: true, release }).filter( - config => release || config.name === 'modern' -); -function build() { +function clean() { + fs.emptyDirSync(paths.appBuild); +} + +async function build() { + const start = performance.now(); console.log(chalk.cyan.bold(`Creating ${release ? 'optimized' : 'fast'} production build...`)); console.log(); - webpack(configs, (err, stats) => { - if (err) { - console.log(chalk.red.bold('Failed to create a production build!')); - console.log(chalk.red(err.message || err)); - process.exit(1); - } - reportBuildStats(stats.stats[0], 'modern'); + await esbuild.build(getConfig(release)); + + console.log(chalk.green.bold('Compiled successfully!')); + console.log(chalk.cyan(Math.round(performance.now() - start), 'ms')); + console.log(); +} - console.log(chalk.green.bold('Compiled successfully!')); - }); +function copyAssets() { + fs.copySync(paths.appPublic, paths.appBuild); + fs.copySync(paths.docImages, paths.appBuild + '/images/embed-doc/images'); } -build(); +(async () => { + clean(); + await build(); + copyAssets(); +})(); |