aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2019-03-27 16:06:20 +0100
committersonartech <sonartech@sonarsource.com>2019-03-29 09:45:00 +0100
commitcb53cd80dd1167d68caaee15cfcec058b01fff5d (patch)
treea37d015c56108b406dd2130cacc9ec447aec1863
parent0c5b4644cf0ca5487516c581530c67a86bc0342f (diff)
downloadsonarqube-cb53cd80dd1167d68caaee15cfcec058b01fff5d.tar.gz
sonarqube-cb53cd80dd1167d68caaee15cfcec058b01fff5d.zip
Improve front end local build time
-rw-r--r--server/sonar-docs/build.gradle6
-rw-r--r--server/sonar-docs/package.json5
-rw-r--r--server/sonar-web/build.gradle4
-rw-r--r--server/sonar-web/config/webpack.config.js26
-rw-r--r--server/sonar-web/package.json1
-rw-r--r--server/sonar-web/scripts/build.js13
-rw-r--r--sonar-application/build.gradle16
7 files changed, 40 insertions, 31 deletions
diff --git a/server/sonar-docs/build.gradle b/server/sonar-docs/build.gradle
index 6112b5ecca5..b26889a8fa7 100644
--- a/server/sonar-docs/build.gradle
+++ b/server/sonar-docs/build.gradle
@@ -12,7 +12,7 @@ yarn_run {
environment = [ GATSBY_DOCS_VERSION: version ]
inputs.property('version', version)
inputs.dir('src').withPathSensitivity(PathSensitivity.RELATIVE)
- ['gatsby-config.js', 'gatsby-node.js', 'package.json'].each {
+ ['gatsby-config.js', 'gatsby-node.js', 'package.json', 'yarn.lock', 'tsconfig.json'].each {
inputs.file(it).withPathSensitivity(PathSensitivity.RELATIVE)
}
outputs.dir('public')
@@ -20,10 +20,6 @@ yarn_run {
args = ['build']
}
-task "yarn_validate-ci"() {
-
-}
-
task "yarn_lint-report"() {
}
diff --git a/server/sonar-docs/package.json b/server/sonar-docs/package.json
index f85cb95950c..db49904f1a0 100644
--- a/server/sonar-docs/package.json
+++ b/server/sonar-docs/package.json
@@ -55,7 +55,7 @@
"unist-util-visit": "1.4.0"
},
"scripts": {
- "build": "gatsby clean && yarn jest src/__tests__/ && gatsby build --prefix-paths",
+ "build": "gatsby clean && gatsby build --prefix-paths",
"develop": "gatsby develop",
"graphql-types": "gql-gen --url http://localhost:8000/___graphql --template typescript --out ./src/@types/graphql-types.d.ts",
"test": "jest",
@@ -63,7 +63,8 @@
"format-check": "prettier --list-different 'src/**/*.{js,ts,tsx,css}'",
"lint": "eslint --ext js,ts,tsx --quiet src",
"ts-check": "tsc --noEmit",
- "validate": "yarn lint && yarn ts-check && yarn format-check && yarn test"
+ "validate": "yarn lint && yarn ts-check && yarn format-check && yarn test",
+ "validate-ci": "yarn lint && yarn ts-check && yarn format-check && yarn test"
},
"prettier": {
"jsxBracketSameLine": true,
diff --git a/server/sonar-web/build.gradle b/server/sonar-web/build.gradle
index 07b6127d162..c522d9a17a4 100644
--- a/server/sonar-web/build.gradle
+++ b/server/sonar-web/build.gradle
@@ -26,6 +26,8 @@ yarn_run {
if (official) { dependsOn copyBranding }
inputs.property('official', official)
+ inputs.property('release', release)
+
['config', 'public', 'scripts', 'src', '../sonar-docs/src'].each {
inputs.dir(it).withPathSensitivity(PathSensitivity.RELATIVE)
}
@@ -34,7 +36,7 @@ yarn_run {
}
outputs.dir(webappDir)
outputs.cacheIf { true }
- args = ['build']
+ args = [release ? 'build-release' : 'build']
}
build.dependsOn(yarn_run)
diff --git a/server/sonar-web/config/webpack.config.js b/server/sonar-web/config/webpack.config.js
index 97aa7dc4eef..ec6ed103d5d 100644
--- a/server/sonar-web/config/webpack.config.js
+++ b/server/sonar-web/config/webpack.config.js
@@ -53,12 +53,12 @@ const utils = require('./utils');
https://github.com/jantimon/html-webpack-plugin/issues/1051
*/
-module.exports = ({ production = true }) => {
+module.exports = ({ production = true, release = false }) => {
const timestamp = Date.now();
const commonConfig = {
mode: production ? 'production' : 'development',
- devtool: production ? 'source-map' : 'cheap-module-source-map',
+ devtool: production && release ? 'source-map' : 'cheap-module-source-map',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.ts', '.tsx', '.js', '.json'],
@@ -71,7 +71,8 @@ module.exports = ({ production = true }) => {
splitChunks: {
chunks: 'all',
automaticNameDelimiter: '-'
- }
+ },
+ minimize: production && release
}
};
@@ -177,7 +178,7 @@ module.exports = ({ production = true }) => {
new HtmlWebpackPlugin({
inject: false,
template: paths.appHtml,
- minify: utils.minifyParams({ production }),
+ minify: utils.minifyParams({ production: production && release }),
timestamp
}),
@@ -192,14 +193,15 @@ module.exports = ({ production = true }) => {
!production && new webpack.HotModuleReplacementPlugin()
].filter(Boolean),
- performance: production
- ? {
- // ignore source maps and documentation chunk
- assetFilter: assetFilename =>
- !assetFilename.endsWith('.map') && !assetFilename.startsWith('js/docs.'),
- hints: 'error'
- }
- : undefined
+ performance:
+ production && release
+ ? {
+ // ignore source maps and documentation chunk
+ assetFilter: assetFilename =>
+ !assetFilename.endsWith('.map') && !assetFilename.startsWith('js/docs.'),
+ hints: 'error'
+ }
+ : undefined
}),
Object.assign({ name: 'legacy' }, commonConfig, {
diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json
index a53eaeabce7..632f98c71a2 100644
--- a/server/sonar-web/package.json
+++ b/server/sonar-web/package.json
@@ -132,6 +132,7 @@
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
+ "build-release": "node scripts/build.js release",
"test": "jest",
"format": "prettier --write --list-different 'src/main/js/**/*.{js,ts,tsx,css}'",
"format-check": "prettier --list-different 'src/main/js/**/*.{js,ts,tsx,css}'",
diff --git a/server/sonar-web/scripts/build.js b/server/sonar-web/scripts/build.js
index 4e0c66a7bf5..6717054f361 100644
--- a/server/sonar-web/scripts/build.js
+++ b/server/sonar-web/scripts/build.js
@@ -25,10 +25,13 @@ const webpack = require('webpack');
const reportBuildStats = require('./utils/reportBuildStats');
const getConfigs = require('../config/webpack.config');
-const configs = getConfigs({ production: true });
+const release = process.argv.findIndex(val => val === 'release') >= 0;
+const configs = getConfigs({ production: true, release }).filter(
+ config => release || config.name === 'modern'
+);
function build() {
- console.log(chalk.cyan.bold('Creating optimized production build...'));
+ console.log(chalk.cyan.bold(`Creating ${release ? 'optimized' : 'fast'} production build...`));
console.log();
webpack(configs, (err, stats) => {
@@ -38,8 +41,10 @@ function build() {
process.exit(1);
}
reportBuildStats(stats.stats[0], 'modern');
- console.log();
- reportBuildStats(stats.stats[1], 'legacy');
+ if (release) {
+ console.log();
+ reportBuildStats(stats.stats[1], 'legacy');
+ }
console.log(chalk.green.bold('Compiled successfully!'));
});
}
diff --git a/sonar-application/build.gradle b/sonar-application/build.gradle
index 7c5dfe538ed..49d88885093 100644
--- a/sonar-application/build.gradle
+++ b/sonar-application/build.gradle
@@ -175,13 +175,15 @@ zip.doFirst {
}
// Check the size of the archive
zip.doLast {
- def minLength = 191000000
- def maxLength = 198000000
- def length = new File(distsDir, archiveName).length()
- if (length < minLength)
- throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
- if (length > maxLength)
- throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
+ if (release) {
+ def minLength = 191000000
+ def maxLength = 198000000
+ def length = new File(distsDir, archiveName).length()
+ if (length < minLength)
+ throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
+ if (length > maxLength)
+ throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
+ }
}
assemble.dependsOn zip