Gruntfile.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 63
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 63
rs 10
c 0
b 0
f 0
cc 0
nc 1
mnd 0
bc 2
fnc 2
bpm 1
cpm 1
noi 0
1
module.exports = function(grunt) {
2
    var BUNDLE_NAME = 'sulucomment',
3
        SOURCE_PATH = BUNDLE_NAME + '/js',
4
        DIST_PATH = BUNDLE_NAME + '/dist',
5
        replaceVariables = {},
6
        min = {},
7
        path = require('path'),
8
        srcpath = 'Resources/public/js',
9
        destpath = 'Resources/public/dist';
10
11
    // Build config "min" object dynamically.
12
    grunt.file.expand({cwd: srcpath}, '**/*.js').forEach(function(relpath) {
13
        // Create a target Using the verbose "target: {src: src, dest: dest}" format.
14
        min[relpath] = {
15
            src: path.join(srcpath, relpath),
16
            dest: path.join(destpath, relpath)
17
        };
18
        // The more compact "dest: src" format would work as well.
19
        // min[path.join(destpath, relpath)] = path.join(srcpath, relpath);
20
    });
21
22
    // load all grunt tasks
23
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
24
25
    replaceVariables[SOURCE_PATH] = DIST_PATH;
26
27
    grunt.initConfig({
28
        pkg: grunt.file.readJSON('package.json'),
29
        uglify: min,
30
        copy: {
31
            templates: {
32
                files: [
33
                    {expand: true, cwd: srcpath, src: ['**/*.html'], dest: destpath}
34
                ]
35
            }
36
        },
37
        replace: {
38
            build: {
39
                options: {
40
                    variables: replaceVariables,
41
                    prefix: ''
42
                },
43
                files: [
44
                    {src: ['Resources/public/dist/main.js'], dest: 'Resources/public/dist/main.js'}
45
                ]
46
            }
47
        }
48
    });
49
50
    grunt.registerTask('build:js', [
51
        'copy:templates',
52
        'uglify',
53
        'replace:build'
54
    ]);
55
56
    grunt.registerTask('build', [
57
        'build:js'
58
    ]);
59
60
    grunt.registerTask('default', [
61
        'build'
62
    ]);
63
};
64