/
Gruntfile.js
133 lines (121 loc) · 4.24 KB
/
Gruntfile.js
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
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compass: { // Task
dist: { // Target
options: { // Target options
sassDir: 'assets/scss/app.scss',
cssDir: 'assets/css/appp.css',
environment: 'production'
}
},
dev: { // Another target
options: {
sassDir: 'assets/scss',
cssDir: 'assets/css'
}
}
},
sass: {
all: {
options: {
//style: 'nested',
style: 'expanded',
//sourcemap: 'true',
//check: 'true',
//trace: 'true',
//quiet: 'true',
//debugInfo: 'true',
//lineNumbers: 'true',
cacheLocation: './.sass-cache'
},
files: {
'assets/css/app-withoutprefix.css': 'assets/scss/app.scss'
}
}
},
watch: {
all: {
files: ['assets/js/*.js', 'assets/scss/*.scss', 'application/views/*.tpl', 'application/views/backoffice/*.tpl', 'application/controllers/*.php', '/Gruntfile.js'],
tasks: ['sass:dev'],
options: {
//spawn: false,
livereload: true
}
},
js: {
files: '**/*.js',
tasks: ['jshint'],
options: {
interrupt: true
}
},
tpl: {
files: ['application/views/*.tpl'],
//tasks: ['tpl'],
options: {
livereload: true
}
},
sass: {
files: ['assets/scss/*.scss'],
tasks: ['sass:dev', 'autoprefixer:autoprefix'],
options: {
livereload: true
}
}
},
// gzip assets 1-to-1 for production
compress: {
main: {
options: {
mode: 'gzip'
},
//expand: true,
//cwd: 'assets/',
files: {
'assets/css/app.gzip': 'assets/css/app.css'
}
}
},
// cssmin
cssmin: {
minify: {
expand: false,
src: 'assets/css/app.css',
dest: 'assets/css/app.min.css',
ext: '.min.css'
}
},
// Auto prefix CSS
autoprefixer: {
options: {
browsers: ['last 8 versions']
},
autoprefix: {
src: 'assets/css/app-withoutprefix.css',
dest: 'assets/css/app.css'
},
}
});
// grunt-sass : Compile Sass to CSS using node-sass
/* Node-sass is a library that provides binding for Node.js to libsass, the C version of the popular stylesheet
preprocessor, Sass. It allows you to natively compile .scss files to css at incredible speed and automatically
via a connect middleware. */
grunt.loadNpmTasks('grunt-sass');
/* */
// grunt-contrib-sass : Compile Sass to CSS
//grunt.loadNpmTasks('grunt-contrib-sass');
// Run predefined tasks whenever watched file patterns are added, changed or deleted.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-autoprefixer');
//grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-cssmin');
//grunt.loadNpmTasks('grunt-contrib-uglify');
//grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('default', ['sass:all', 'autoprefixer:autoprefix', 'watch:sass']);
grunt.registerTask('prod', ['sass:all', 'autoprefixer:autoprefix', 'cssmin:minify']);
grunt.registerTask('dev', ['sass:all']);
grunt.registerTask('zip', ['compress:main']);
grunt.registerTask('css-min', ['cssmin:minify']);
}