Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/273780

Change subject: Add a build task to the Gruntfile
......................................................................

Add a build task to the Gruntfile

This minifies some of the js. To use this, we need to
modify the deploy process to include this.

e.g. see https://github.com/wikimedia/wikidata-query-deploy
and might need something like what parsoid does:
https://github.com/wikimedia/mediawiki-services-parsoid-deploy

I think as we include more js libraries, this is something
we should be doing.

Change-Id: Ida161239a681ee4eeddedfdccd34bbdd9a4ef82e
---
A .gitignore
M Gruntfile.js
M README.md
M index.html
M package.json
5 files changed, 75 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/80/273780/1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..de4d1f0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+dist
+node_modules
diff --git a/Gruntfile.js b/Gruntfile.js
index c380dc7..357566a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,9 +1,15 @@
 /*jshint node:true */
 module.exports = function ( grunt ) {
        'use strict';
+
+       grunt.loadNpmTasks( 'grunt-contrib-clean' );
+       grunt.loadNpmTasks( 'grunt-contrib-concat' );
+       grunt.loadNpmTasks( 'grunt-contrib-copy' );
        grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+       grunt.loadNpmTasks( 'grunt-contrib-uglify' );
        grunt.loadNpmTasks( 'grunt-jsonlint' );
        grunt.loadNpmTasks( 'grunt-jscs' );
+       grunt.loadNpmTasks( 'grunt-useref' );
 
        grunt.initConfig( {
                jshint: {
@@ -12,6 +18,7 @@
                        },
                        all: [
                                '**/*.js',
+                               '!dist/**'
                        ]
                },
                jscs: {
@@ -20,12 +27,48 @@
                jsonlint: {
                        all: [
                                '**/*.json',
+                               '!dist/**',
                                '!node_modules/**',
                                '!vendor/**'
                        ]
+               },
+               clean: [ 'dist/**/*' ],
+               copy: {
+                       main: {
+                               src: [
+                                       '*.html',
+                                       '*.css',
+                                       '*.js',
+                                       'robots.txt',
+                                       'vendor/**',
+                                       '!node_modules'
+                               ],
+                               dest: 'dist/'
+                       }
+               },
+               concat: {
+                       js: {
+                               files: {
+                                       'dist/js/wdqs-explorer.js': 
'vendor/wdqs-explorer/**/*.js',
+                                       'dist/js/wikibase.js': 
'wikibase/**/*.js'
+                               }
+                       }
+               },
+               uglify: {
+                       bundle: {
+                               files: {
+                                       'dist/js/wdqs-explorer.min.js': 
'dist/js/wdqs-explorer.js',
+                                       'dist/js/wikibase.min.js': 
'dist/js/wikibase.js'
+                               }
+                       }
+               },
+               useref: {
+                       html: 'dist/index.html',
+                       temp: '/'
                }
        } );
 
        grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint' ] );
+       grunt.registerTask( 'build', [ 'test', 'clean', 'copy', 'concat', 
'uglify', 'useref' ] );
        grunt.registerTask( 'default', 'test' );
 };
diff --git a/README.md b/README.md
index fb51ba4..02936e3 100644
--- a/README.md
+++ b/README.md
@@ -4,3 +4,19 @@
 This repository contains the GUI for the [Wikidata Query 
Service](https://query.wikidata.org/).
 
 Please see more details about the service in the [User 
Manual](https://www.mediawiki.org/wiki/Wikidata_query_service/User_Manual).
+
+## Build
+
+First, install grunt and run npm install.
+
+To make a build, run:
+
+```
+grunt build
+```
+
+To clean a build, run:
+
+```
+grunt clean
+```
diff --git a/index.html b/index.html
index d6c865d..e277de3 100644
--- a/index.html
+++ b/index.html
@@ -168,7 +168,8 @@
                        </div>
                </div>
        </div>
-<!-- JS files -->
+
+       <!-- JS files -->
        <script src="mediawiki.js"></script>
 
        <script src="vendor/jquery/jquery-1.11.3.js"></script>
@@ -180,11 +181,14 @@
        <script src="vendor/jqcloud/jqcloud-1.0.4.min.js"></script>
        <script src="vendor/bootstrap-tags/js/bootstrap-tags.min.js"></script>
        <script src="vendor/danml/download.min.js"></script>
+       <script src="vendor/lightbox/ekko-lightbox.min.js"></script>
+
+       <!-- build:js js/wdqs-explorer.min.js -->
        <script src="vendor/wdqs-explorer/vis.js"></script>
        <script src="vendor/wdqs-explorer/wdqs.js"></script>
        <script src="vendor/wdqs-explorer/wdqs-explorer.js"></script>
-       <script src="vendor/lightbox/ekko-lightbox.min.js"></script>
-
+       <!-- endbuild -->
+       <!-- build:js js/wikibase.min.js -->
        <script 
src="wikibase/codemirror/addon/hint/wikibase-sparql-hint.js"></script>
        <script 
src="wikibase/codemirror/addon/hint/wikibase-rdf-hint.js"></script>
        <script 
src="wikibase/codemirror/addon/tooltip/WikibaseRDFTooltip.js"></script>
@@ -199,5 +203,6 @@
        <script src="wikibase/queryService/api/QuerySamples.js"></script>
        <script src="wikibase/queryService/RdfNamespaces.js"></script>
        <script src="wikibase/init.js"></script>
+       <!-- endbuild -->
 </body>
 </html>
diff --git a/package.json b/package.json
index 8b670dc..18d73b8 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,13 @@
   "devDependencies": {
     "grunt": "0.4.5",
     "grunt-cli": "0.1.13",
+    "grunt-contrib-clean": "^1.0.0",
+    "grunt-contrib-concat": "^1.0.0",
+    "grunt-contrib-copy": "^0.8.2",
     "grunt-contrib-jshint": "0.11.2",
+    "grunt-contrib-uglify": "^0.11.1",
     "grunt-jscs": "2.1.0",
-    "grunt-jsonlint": "1.0.4"
+    "grunt-jsonlint": "1.0.4",
+    "grunt-useref": "0.0.16"
   }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/273780
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida161239a681ee4eeddedfdccd34bbdd9a4ef82e
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to