1- // Build configurations.
21module . exports = function ( grunt ) {
32 grunt . loadNpmTasks ( 'grunt-karma' ) ;
43 grunt . loadNpmTasks ( 'grunt-contrib-connect' ) ;
54 grunt . loadNpmTasks ( 'grunt-contrib-watch' ) ;
65 grunt . loadNpmTasks ( 'grunt-contrib-jshint' ) ;
76 grunt . loadNpmTasks ( 'grunt-contrib-copy' ) ;
7+ grunt . loadNpmTasks ( 'grunt-contrib-clean' ) ;
88 grunt . loadNpmTasks ( 'grunt-webpack' ) ;
99
10+ var webpackSettings = require ( './webpack.config.js' ) ;
11+
1012 grunt . initConfig ( {
1113 connect : {
1214 app : {
@@ -30,36 +32,34 @@ module.exports = function (grunt) {
3032 }
3133 } ,
3234 karma : {
33- dev : {
34- options : {
35- autoWatch : true ,
36- colors : true ,
37- configFile : './test/karma.conf.js' ,
38- keepalive : true ,
39- port : 8082 ,
40- runnerPort : 9100
41- }
35+ options : {
36+ configFile : './test/karma.conf.js' ,
37+ runnerPort : 9100
4238 } ,
43- prod : {
39+ default : { } ,
40+ compressed : {
4441 options : {
45- colors : true ,
46- configFile : './test/karma.conf.js' ,
47- runnerPort : 9100 ,
42+ files : require ( './test/karma.conf.files.js' ) . compressedFiles ,
43+ port : 9876 ,
44+ autoWatch : false ,
45+ keepalive : false ,
4846 singleRun : true
4947 }
5048 }
5149 } ,
5250 webpack : {
53- options : require ( "./webpack.config.js" ) . config ,
54- prod : {
55- cache : false ,
56- plugins : require ( "./webpack.config.js" ) . prodPlugins
57- } ,
58- dev : {
59- cache : false ,
60- plugins : require ( "./webpack.config.js" ) . devPlugins
51+ options : webpackSettings . config ,
52+ default : { } ,
53+ compressed : {
54+ plugins : webpackSettings . compressedPlugins ,
55+ output : {
56+ filename : '[name].min.js'
57+ }
6158 }
6259 } ,
60+ clean : {
61+ temp : [ 'temp' ]
62+ } ,
6363 copy : {
6464 sources : {
6565 files : [
@@ -69,6 +69,9 @@ module.exports = function (grunt) {
6969 jqLiteExtrasFake : {
7070 files : [
7171 { expand : true , src : [ 'ui-scroll-jqlite.js' ] , cwd : 'src' , dest : 'dist/' } ,
72+ { expand : true , src : [ 'ui-scroll-jqlite.js' ] , cwd : 'src' , dest : 'dist/' , rename : function ( dest , src ) {
73+ return dest + src . replace ( / \. j s $ / , ".min.js" ) ;
74+ } }
7275 ]
7376 }
7477 } ,
@@ -109,11 +112,6 @@ module.exports = function (grunt) {
109112 }
110113 } ) ;
111114
112- /**
113- * Starts a web server
114- * Enter the following command at the command line to execute this task:
115- * grunt server
116- */
117115 grunt . registerTask ( 'server' , [
118116 'connect' ,
119117 'watch'
@@ -122,26 +120,30 @@ module.exports = function (grunt) {
122120 grunt . registerTask ( 'default' , [ 'server' ] ) ;
123121
124122 grunt . registerTask ( 'test' , [
125- 'webpack:dev' ,
126- 'karma:dev'
123+ 'clean:temp' ,
124+ 'webpack:default' ,
125+ 'karma:default'
127126 ] ) ;
128127
129128 grunt . registerTask ( 'buildWatcher' , [
130129 'jshint:sources' ,
131- 'webpack:dev'
130+ 'clean:temp' ,
131+ 'webpack:default'
132132 ] ) ;
133133
134134 grunt . registerTask ( 'build' , [
135135 'jshint:tests' ,
136136 'jshint:sources' ,
137- 'webpack:prod' ,
138- 'karma:prod' ,
137+ 'clean:temp' ,
138+ 'webpack:compressed' ,
139+ 'karma:compressed' ,
140+ 'webpack:default' ,
139141 'copy:sources' ,
140142 'copy:jqLiteExtrasFake'
141143 ] ) ;
142144
143145 grunt . registerTask ( 'travis' , [
144- 'webpack:prod ' ,
145- 'karma:prod '
146+ 'webpack:compressed ' ,
147+ 'karma:compressed '
146148 ] ) ;
147149} ;
0 commit comments