aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/config
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2019-05-08 12:17:40 +0200
committerSonarTech <sonartech@sonarsource.com>2019-05-13 20:21:17 +0200
commite6a4c4b798b3ee46bf618e45c259ab4065ce59f5 (patch)
tree2768c7616bce028537bc302c81af5e4b822681df /server/sonar-web/config
parentcfcd9fa1d857a23390f8210637e51352d8c4e619 (diff)
downloadsonarqube-e6a4c4b798b3ee46bf618e45c259ab4065ce59f5.tar.gz
sonarqube-e6a4c4b798b3ee46bf618e45c259ab4065ce59f5.zip
Better minify inline CSS
Diffstat (limited to 'server/sonar-web/config')
-rw-r--r--server/sonar-web/config/utils.js18
-rw-r--r--server/sonar-web/config/webpack.config.js6
2 files changed, 9 insertions, 15 deletions
diff --git a/server/sonar-web/config/utils.js b/server/sonar-web/config/utils.js
index e8b926ad671..754dd9d78c7 100644
--- a/server/sonar-web/config/utils.js
+++ b/server/sonar-web/config/utils.js
@@ -17,15 +17,11 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-const cssMinimizeOptions = {
- discardComments: { removeAll: true }
-};
-
-const cssLoader = ({ production }) => ({
+const cssLoader = () => ({
loader: 'css-loader',
options: {
importLoaders: 1,
- minimize: production && cssMinimizeOptions,
+ modules: 'global',
url: false
}
});
@@ -39,17 +35,15 @@ Object.keys(theme).forEach(key => {
}
});
-const postcssLoader = () => ({
+const postcssLoader = production => ({
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [
require('autoprefixer'),
- require('postcss-custom-properties')({
- importFrom: { customProperties },
- preserve: false
- }),
- require('postcss-calc')
+ require('postcss-custom-properties')({ importFrom: { customProperties }, preserve: false }),
+ require('postcss-calc'),
+ ...(production ? [require('cssnano')({ calc: false, svgo: false })] : [])
]
}
});
diff --git a/server/sonar-web/config/webpack.config.js b/server/sonar-web/config/webpack.config.js
index ec6ed103d5d..651621f2c51 100644
--- a/server/sonar-web/config/webpack.config.js
+++ b/server/sonar-web/config/webpack.config.js
@@ -83,15 +83,15 @@ module.exports = ({ production = true, release = false }) => {
include: path.resolve(__dirname, '../src/main/js/app/styles'),
use: [
production ? MiniCssExtractPlugin.loader : 'style-loader',
- utils.cssLoader({ production }),
- utils.postcssLoader()
+ utils.cssLoader(),
+ utils.postcssLoader(production)
]
},
{
// inline all other styles
test: /\.css$/,
exclude: path.resolve(__dirname, '../src/main/js/app/styles'),
- use: ['style-loader', utils.cssLoader({ production }), utils.postcssLoader()]
+ use: ['style-loader', utils.cssLoader(), utils.postcssLoader(production)]
},
{
test: /\.md$/,