X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=Gruntfile.js;h=fbb93bfb6e2716ed8009586b2531d79550206cbd;hp=fec43f343ca534ef54bda04b527378a9f2dea6f2;hb=a38af7ba26579bb3004f673e44d39710887763aa;hpb=c81e1506c642c00e1cd248c6b9b39bb099c367c2 diff --git a/Gruntfile.js b/Gruntfile.js index fec43f343c..fbb93bfb6e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,11 +8,11 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-contrib-copy' ); - grunt.loadNpmTasks( 'grunt-contrib-watch' ); grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-karma' ); grunt.loadNpmTasks( 'grunt-stylelint' ); + grunt.loadNpmTasks( 'grunt-svgmin' ); karmaProxy[ wgScriptPath ] = { target: wgServer + wgScriptPath, @@ -22,7 +22,8 @@ module.exports = function ( grunt ) { grunt.initConfig( { eslint: { options: { - reportUnusedDisableDirectives: true + reportUnusedDisableDirectives: true, + cache: true }, all: [ '**/*.js', @@ -57,6 +58,41 @@ module.exports = function ( grunt ) { stylelint: { src: '{resources/src,mw-config}/**/*.{css,less}' }, + svgmin: { + options: { + js2svg: { + indent: '\t', + pretty: true + }, + multipass: true, + plugins: [ { + cleanupIDs: false + }, { + removeDesc: false + }, { + removeRasterImages: true + }, { + removeTitle: false + }, { + removeViewBox: false + }, { + removeXMLProcInst: false + }, { + sortAttrs: true + } ] + }, + all: { + files: [ { + expand: true, + cwd: 'resources/src', + src: [ + '**/*.svg' + ], + dest: 'resources/src/', + ext: '.svg' + } ] + } + }, watch: { files: [ '.{stylelintrc,eslintrc.json}', @@ -67,6 +103,18 @@ module.exports = function ( grunt ) { }, karma: { options: { + customLaunchers: { + ChromeCustom: { + base: 'ChromeHeadless', + // Chrome requires --no-sandbox in Docker/CI. + // Newer CI images expose CHROMIUM_FLAGS which sets this (and + // anything else it might need) automatically. Older CI images, + // (including Quibble for MW) don't set it yet. + flags: ( process.env.CHROMIUM_FLAGS || + ( process.env.ZUUL_PROJECT ? '--no-sandbox' : '' ) + ).split( ' ' ) + } + }, proxies: karmaProxy, files: [ { pattern: wgServer + wgScriptPath + '/index.php?title=Special:JavaScriptTest/qunit/export', @@ -86,13 +134,10 @@ module.exports = function ( grunt ) { crossOriginAttribute: false }, main: { - browsers: [ 'Chrome' ] - }, - chromium: { - browsers: [ 'Chromium' ] + browsers: [ 'ChromeCustom' ] }, firefox: { - browsers: [ 'Firefox' ] + browsers: [ 'FirefoxHeadless' ] } }, copy: { @@ -120,9 +165,7 @@ module.exports = function ( grunt ) { return !!( process.env.MW_SERVER && process.env.MW_SCRIPT_PATH ); } ); + grunt.registerTask( 'minify', 'svgmin' ); grunt.registerTask( 'lint', [ 'eslint', 'banana', 'stylelint' ] ); grunt.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] ); - - grunt.registerTask( 'test', [ 'lint' ] ); - grunt.registerTask( 'default', 'test' ); };