-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
129 lines (124 loc) · 3.16 KB
/
Gruntfile.js
File metadata and controls
129 lines (124 loc) · 3.16 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
files: {
'src/css/style.css' : 'src/css/style.scss'
}
}
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'src/css',
src: ['style.css', '!*.min.css'],
dest: 'dist/css',
ext: '.css'
},
{
expand: true,
cwd: 'css',
src: ['critical.css', '!*.min.css'],
dest: 'css',
ext: '.min.css'
}]
},
},
uglify: {
options: {
mangle: true
},
my_target: {
files: {
'dist/js/main.min.js': ['src/js/*.js']
}
}
},
criticalcss: {
custom: {
options: {
url: '127.0.0.1:9000/src/',
width: 1200,
height: 900,
outputfile: 'dist/css/critical.css',
filename: 'src/css/style.css', // Using path.resolve( path.join( ... ) ) is a good idea here
buffer: 800 * 1024
}
}
},
inline: {
dist: {
src: 'src/index.html',
dest: 'dist/index.html'
}
},
dev_prod_switch: {
options: {
environment: 'dev',
env_char: '#',
env_block_dev: 'env:dev',
env_block_prod: 'env:prod'
},
all: {
files: {
'dist/index.html': 'dist/index.html',
'dist/js/main.js': 'dist/js/main.js'
}
}
},
watch: {
css: {
files: 'src/css/*.scss',
tasks: ['sass','cssmin'],
//tasks: ['sass', 'criticalcss', 'cssmin', 'inline']
options: { livereload: true }
},
html: {
files: 'src/*.html',
tasks: ['inline'],
options: { livereload: true }
},
js : {
files: 'src/js/*.js',
tasks: ['uglify'],
options: { livereload: true }
},
svg : {
files: 'src/img/*.svg',
tasks: ['svgmin'],
options: { livereload: true }
},
livereload: {
// Here we watch the files the sass task will compile to
// These files are sent to the live reload server after sass compiles to them
options: { livereload: true },
files: ['dist/**/*'],
}
},
connect: {
all: {
options:{
port: 9000,
hostname: '0.0.0.0'
// Prevents Grunt to close just after the task (starting the server) completes
// This will be removed later as `watch` will take care of that
//keepalive: true
}
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-svgmin');
grunt.loadNpmTasks('grunt-criticalcss');
grunt.loadNpmTasks('grunt-inline');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-dev-prod-switch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['sass', 'cssmin', 'inline', 'uglify']);
grunt.registerTask('images', ['svgmin', 'cssmin']);
grunt.registerTask('server', ['connect','watch']);
}