grunt-contrib-compress(とnginx)でトラフィックを軽くしよう

gzip_static on;
npm install -g grunt-contrib-compress
 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
compress: {
    all: {
        options: {
            mode: 'gzip',
            level: 9
        },
        files: [{
            expand: true,
            cwd: '<%= config.dist %>',
            dest: '<%= config.dist %>',
            src: ['**/*.js'],
            ext: '.js.gz',
            extDot: 'last'
        },{
            expand: true,
            cwd: '<%= config.dist %>',
            dest: '<%= config.dist %>',
            src: ['**/*.css'],
            ext: '.css.gz',
            extDot: 'last'
        },{
            expand: true,
            cwd: '<%= config.dist %>',
            dest: '<%= config.dist %>',
            src: ['**/*.html'],
            ext: '.html.gz',
            extDot: 'last'
        }]
    }
},
grunt.registerTask('deploy', [
    'build',
    'compress:all',
    'rsync:prod'
]);

Comments

comments powered by Disqus