Gruntfile.js 18.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
module.exports = function (grunt) {
    // grunt配置,插件配置
    grunt.initConfig({
        // 调用grunt相关api,用于读取package.json文件信息
        // pkg相当于定义了一个变量,可以通过 <%== 变量 %>在后面调用
        pkg: grunt.file.readJSON('package.json'),

        // 这里插件的每个子任务代表一个功能,子任务名就用文件夹名,便于管理

        // clean清除插件配置
        clean: {
            concat_directive: { // 所有指令合并的js文件
                src: ['module/common/prj-common-directive.js']
            }

            //,
            //
            //demo: { // demo模块
            //    src: ['app/demo/tmp/', 'app/demo/dist/']
            //},
            //busInfoManage: { // 车辆信息管理模块
            //    src: ['app/basicInfo/busInfoManage/tmp/', 'app/basicInfo/busInfoManage/dist/']
            //},
            //deviceInfoManage: { // 设备信息管理模块
            //    src: ['app/basicInfo/deviceInfoManage/tmp/', 'app/basicInfo/deviceInfoManage/dist/']
            //},
            //employeeInfoManage: { // 人员信息管理模块
            //    src: ['app/basicInfo/employeeInfoManage/tmp/', 'app/basicInfo/employeeInfoManage/dist/']
            //},
            //busConfig: { // 车辆配置模块
            //    src: ['app/core/busConfig/tmp/', 'app/core/busConfig/dist/']
            //},
            //busLineInfoOverview: { // 线路运营概览模块
            //    src: ['app/core/busLineInfoOverview/tmp/', 'app/core/busLineInfoOverview/dist/']
            //},
            //dispatchManage: { // 调派管理模块
            //    src: ['app/core/dispatchManage/tmp/', 'app/core/dispatchManage/dist/']
            //},
            //employeeConfig: { // 人员配置模块
            //    src: ['app/core/employeeConfig/tmp/', 'app/core/employeeConfig/dist/']
            //},
            //guideboardManage: { // 路牌管理模块
            //    src: ['app/core/guideboardManage/tmp/', 'app/core/guideboardManage/dist/']
            //},
            //rerunManage: { // 套跑管理模块
            //    src: ['app/core/rerunManage/tmp/', 'app/core/rerunManage/dist/']
            //},
            //schedulePlanManage: { // 排班计划管理模块
            //    src: ['app/core/schedulePlanManage/tmp/', 'app/core/schedulePlanManage/dist/']
            //},
            //scheduleRuleManage: { // 排班规则管理模块
            //    src: ['app/core/scheduleRuleManage/tmp/', 'app/core/scheduleRuleManage/dist/']
            //},
            //timeTableManage: { // 时刻表管理模块
            //    src: ['app/core/timeTableManage/tmp/', 'app/core/timeTableManage/dist/']
            //}
        },

        // concat合并文件插件配置
        concat: {
            directive: {
                options: {
                    banner: '//自定义指令'
                },
                src: [
                    'module/common/dts1/load/loadingWidget.js', // loading界面指令
                    'module/common/dts1/validation/remoteValidation.js',// 服务端验证指令
                    'module/common/dts1/validation/remoteValidationt2.js',// 服务端验证指令(时刻表专用)
                    'module/common/dts1/select/saSelect.js', // select整合指令1
                    'module/common/dts1/select/saSelect2.js', // select整合指令2
                    'module/common/dts1/select/saSelect3.js', // select整合指令3
                    'module/common/dts1/select/saSelect4.js', // select整合指令4
                    'module/common/dts1/select/saSelect5.js', // select整合指令5
                    'module/common/dts1/radioButton/saRadiogroup.js', // 单选框组整合指令
                    'module/common/dts1/checkbox/saCheckboxgroup.js', // 多选框组整合指令
                    'module/common/dts2/dateGroup/saDategroup.js', // 特殊日期选择指令
                    'module/common/dts2/guideboardGroup/saGuideboardgroup.js', // 路牌选择整合指令
                    'module/common/dts2/employeeGroup/saEmployeegroup.js', // 人员选饿整合指令
                    'module/common/dts2/bcGroup/saBcgroup.js' // 班次选择整合指令
                ],
                dest: 'module/common/prj-common-directive.js'
            }
        },

        // unglify压缩插件配置
        //uglify: {
        //    demo: { // demo模块
        //        files: {
        //            'app/demo/dist/demo1.min.js': ['app/demo/demo1.js']
        //        }
        //    },
        //    busInfoManage: { // 车辆信息管理模块
        //        files: {
        //            // TODO:
        //        }
        //    },
        //    deviceInfoManage: { // 设备信息管理模块
        //        files: {
        //            // TODO:
        //        }
        //    },
        //    employeeInfoManage: { // 人员信息管理模块
        //        files: {
        //            // TODO:
        //        }
        //    },
        //    busConfig: { // 车辆配置模块
        //        files: {
        //            'app/core/busConfig/dist/service.min.js': ['app/core/busConfig/service.js'],
        //            'app/core/busConfig/dist/controller.min.js': ['app/core/busConfig/controller.js']
        //        }
        //    },
        //    busLineInfoOverview: { // 线路运营概览模块
        //        files: {
        //            'app/core/busLineInfoOverview/dist/service.min.js': ['app/core/busLineInfoOverview/service.js'],
        //            'app/core/busLineInfoOverview/dist/controller.min.js': ['app/core/busLineInfoOverview/controller.js']
        //        }
        //    },
        //    dispatchManage: { // 调派管理模块
        //        files: {
        //            // TODO:
        //        }
        //    },
        //    employeeConfig: { // 人员配置模块
        //        files: {
        //            'app/core/employeeConfig/dist/service.min.js': ['app/core/employeeConfig/service.js'],
        //            'app/core/employeeConfig/dist/controller.min.js': ['app/core/employeeConfig/controller.js']
        //        }
        //    },
        //    guideboardManage: { // 路牌管理模块
        //        files: {
        //            'app/core/guideboardManage/dist/service.min.js': ['app/core/guideboardManage/service.js'],
        //            'app/core/guideboardManage/dist/controller.min.js': ['app/core/guideboardManage/controller.js']
        //        }
        //    },
        //    rerunManage: { // 套跑管理模块
        //        files: {
        //            // TODO:
        //        }
        //    },
        //    schedulePlanManage: { // 排班计划管理模块
        //        files: {
        //            // TODO:
        //        }
        //    },
        //    scheduleRuleManage: { // 排班规则管理模块
        //        files: {
        //            // TODO:
        //        }
        //    },
        //    timeTableManage: { // 时刻表管理模块
        //        files: {
        //            'app/core/timeTableManage/dist/service.min.js': ['app/core/timeTableManage/service.js'],
        //            'app/core/timeTableManage/dist/controller.min.js': ['app/core/timeTableManage/controller.js']
        //        }
        //    }
        //},

        // replace文本替换插件配置
        //replace: {
        //    demo: { // demo模块
        //        src: ["app/demo/demo1.html"],
        //        dest: "app/demo/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    busInfoManage: { // 车辆信息管理模块
        //        src: ["app/basicInfo/busInfoManage/busInfoManage.html"],
        //        dest: "app/basicInfo/busInfoManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    deviceInfoManage: { // 设备信息管理模块
        //        src: ["app/basicInfo/deviceInfoManage/deviceInfoManage.html"],
        //        dest: "app/basicInfo/deviceInfoManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    employeeInfoManage: { // 人员信息管理
        //        src: ["app/basicInfo/employeeInfoManage/employeeInfoManage.html"],
        //        dest: "app/basicInfo/employeeInfoManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    busConfig: { // 车辆配置模块
        //        src: ["app/core/busConfig/busConfig.html"],
        //        dest: "app/core/busConfig/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    busLineInfoOverview: { // 线路运营概览模块
        //        src: ["app/core/busLineInfoOverview/busLineInfoOverview.html"],
        //        dest: "app/core/busLineInfoOverview/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    dispatchManage: { // 调派管理模块
        //        src: ["app/core/dispatchManage/dispatchManage.html"],
        //        dest: "app/core/dispatchManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    employeeConfig: { // 人员配置模块
        //        src: ["app/core/employeeConfig/employeeConfig.html"],
        //        dest: "app/core/employeeConfig/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    guideboardManage: { // 路牌管理模块
        //        src: ["app/core/guideboardManage/guideboardManage.html"],
        //        dest: "app/core/guideboardManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    rerunManage: { // 套跑管理模块
        //        src: ["app/core/rerunManage/rerunManage.html"],
        //        dest: "app/core/rerunManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    schedulePlanManage: { // 排班计划管理模块
        //        src: ["app/core/schedulePlanManage/schedulePlanManage.html"],
        //        dest: "app/core/schedulePlanManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    scheduleRuleManage: { // 排班规则管理模块
        //        src: ["app/core/scheduleRuleManage/scheduleRuleManage.html"],
        //        dest: "app/core/scheduleRuleManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    },
        //    timeTableManage: { // 时刻表管理模块
        //        src: ["app/core/timeTableManage/timeTableManage.html"],
        //        dest: "app/core/timeTableManage/tmp/",
        //        "replacements": [{
        //            from: /(<script src=\")([^\"]*?)(.js\")/mg,
        //            to: '$1dist/$2.min$3'
        //        }]
        //    }
        //},

        // static-inline静态文件插入替换插件配置
        //staticinline: {
        //    demo: { // demo模块
        //        options: {
        //            basepath: 'app/demo/' // 查找路径
        //        },
        //        files: {
        //            'app/demo/dist/demo1.dist.html': 'app/demo/tmp/demo1.html'
        //        }
        //    },
        //    busInfoManage: { // 车辆信息管理模块
        //        options: {
        //            basepath: 'app/basicInfo/busInfoManage'
        //        },
        //        files: {
        //            'app/basicInfo/busInfoManage/dist/busInfoManage.dist.html': 'app/basicInfo/busInfoManage/tmp/busInfoManage.html'
        //        }
        //    },
        //    deviceInfoManage: { // 设备信息管理模块
        //        options: {
        //            basepath: 'app/basicInfo/deviceInfoManage'
        //        },
        //        files: {
        //            'app/basicInfo/deviceInfoManage/dist/deviceInfoManage.dist.html': 'app/basicInfo/deviceInfoManage/tmp/deviceInfoManage.html'
        //        }
        //    },
        //    employeeInfoManage: { // 人员信息管理
        //        options: {
        //            basepath: 'app/basicInfo/employeeInfoManage'
        //        },
        //        files: {
        //            'app/basicInfo/employeeInfoManage/dist/employeeInfoManage.dist.html': 'app/basicInfo/employeeInfoManage/tmp/employeeInfoManage.html'
        //        }
        //    },
        //    busConfig: { // 车辆配置模块
        //        options: {
        //            basepath: 'app/core/busConfig/'
        //        },
        //        files: {
        //            'app/core/busConfig/dist/busConfig.dist.html': 'app/core/busConfig/tmp/busConfig.html'
        //        }
        //    },
        //    busLineInfoOverview: { // 线路运营概览模块
        //        options: {
        //            basepath: 'app/core/busLineInfoOverview/'
        //        },
        //        files: {
        //            'app/core/busLineInfoOverview/dist/busLineInfoOverview.dist.html': 'app/core/busLineInfoOverview/tmp/busLineInfoOverview.html'
        //        }
        //    },
        //    dispatchManage: { // 调派管理模块
        //        options: {
        //            basepath: 'app/core/dispatchManage'
        //        },
        //        files: {
        //            'app/core/dispatchManage/dist/dispatchManage.dist.html': 'app/core/dispatchManage/tmp/dispatchManage.html'
        //        }
        //    },
        //    employeeConfig: { // 人员配置模块
        //        options: {
        //            basepath: 'app/core/employeeConfig/'
        //        },
        //        files: {
        //            'app/core/employeeConfig/dist/employeeConfig.dist.html': 'app/core/employeeConfig/tmp/employeeConfig.html'
        //        }
        //    },
        //    guideboardManage: { // 路牌管理模块
        //        options: {
        //            basepath: 'app/core/guideboardManage/'
        //        },
        //        files: {
        //            'app/core/guideboardManage/dist/guideboardManage.dist.html': 'app/core/guideboardManage/tmp/guideboardManage.html'
        //        }
        //    },
        //    rerunManage: { // 套跑管理模块
        //        options: {
        //            basepath: 'app/core/rerunManage'
        //        },
        //        files: {
        //            'app/core/rerunManage/dist/rerunManage.dist.html': 'app/core/rerunManage/tmp/rerunManage.html'
        //        }
        //    },
        //    schedulePlanManage: { // 排版计划管理模块
        //        options: {
        //            basepath: 'app/core/schedulePlanManage'
        //        },
        //        files: {
        //            'app/core/schedulePlanManage/dist/schedulePlanManage.dist.html': 'app/core/schedulePlanManage/tmp/schedulePlanManage.html'
        //        }
        //    },
        //    scheduleRuleManage: { // 排班规则管理模块
        //        options: {
        //            basepath: 'app/core/scheduleRuleManage'
        //        },
        //        files: {
        //            'app/core/scheduleRuleManage/dist/scheduleRuleManage.dist.html': 'app/core/scheduleRuleManage/tmp/scheduleRuleManage.html'
        //        }
        //    },
        //    timeTableManage: { // 时刻表管理模块
        //        options: {
        //            basepath: 'app/core/timeTableManage/'
        //        },
        //        files: {
        //            'app/core/timeTableManage/dist/timeTableManage.html': 'app/core/timeTableManage/tmp/timeTableManage.html',
        //            'app/core/timeTableManage/dist/timeTableList.html': 'app/core/timeTableManage/timeTableList.html',
        //            'app/core/timeTableManage/dist/timeTableDetail.html': 'app/core/timeTableManage/timeTableDetail.html'
        //        }
        //    }
        //}

    });

    // grunt加载的插件
    grunt.loadNpmTasks("grunt-contrib-clean");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-static-inline");
    grunt.loadNpmTasks("grunt-text-replace");


    // 定义grunt任务列表
    /*
        这里定义了一组任务,并且制定到default任务下,可以一键grunt执行
        任务组有顺序,如下说明:
        1、clean 清除 dist、tmp目录,准备重新生成
        2、uglify 压缩指定的脚本到dist目录,脚本后缀名为.min.js结尾
        3、replace 将指定的html文件复制到tmp目录下,将其中的js后缀名替换成.min.js
        4、staticinline 将.min.js的内容inline-内联插入到tmp的html文件中,然后重命名为.dist.html到dist目录中
     */
    //grunt.registerTask('default', ['clean', 'uglify', 'replace', 'staticinline']);

    /*
        定义了一个directive的grunt任务
        任务组有顺序,如下说明:
        1、clean:concat_directive,清除合并生成的prj-common-directive.js文件
        2、concat:directive,重新合并prj-common-directive.js文件
     */
    grunt.registerTask('directive', ['clean:concat_directive', 'concat:directive']);

};