Completed
Push — master ( 6fb17f...fc53fb )
by Michal
03:05
created

gruntfile.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 65

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 65
rs 9.3571
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
module.exports = (grunt) => {
2
  // Config
3
  const config = {
4
    publicDir: 'www',
5
    buildDir: 'dist',
6
    manifest: 'manifest.json',
7
  };
8
9
  require('load-grunt-tasks')(grunt);
10
  grunt.initConfig({
11
    // JS
12
    babel: {
13
      options: {
14
        presets: ['es2015'],
15
        sourceMap: true,
16
      },
17
      dist: {
18
        files: {
19
          [`${config.publicDir}/${config.buildDir}/js/app.js`]: 'app/scripts/index.js',
20
        }
21
      }
22
    },
23
    // SASS
24
    sass: {
25
      options: {
26
        sourceMap: true
27
      },
28
      dist: {
29
        files: {
30
          [`${config.publicDir}/${config.buildDir}/css/app.css`]: 'app/styles/main.scss',
31
        }
32
      }
33
    },
34
    // Revision manifest
35
    filerev: {
36
      options: {
37
        algorithm: 'md5',
38
        length: 8
39
      },
40
      assets: {
41
        files: [{
42
          src: [
43
            `${config.publicDir}/${config.buildDir}/**/*.{css,js}`,
44
          ]
45
        }]
46
      }
47
    },
48
    filerev_assets: {
49
      dist: {
50
        options: {
51
          dest: `${config.publicDir}/${config.buildDir}/${config.manifest}`,
52
          cwd: `${config.publicDir}/`,
53
          prettyPrint: true,
54
        }
55
      }
56
    },
57
    // Clean
58
    clean: [`${config.publicDir}/${config.buildDir}`],
59
  });
60
61
62
  grunt.loadNpmTasks('grunt-filerev');
63
  grunt.loadNpmTasks('grunt-filerev-assets');
64
  grunt.registerTask('default', ['clean', 'babel', 'sass', 'filerev', 'filerev_assets']);
65
};