-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGruntfile.js
More file actions
124 lines (105 loc) · 2.73 KB
/
Gruntfile.js
File metadata and controls
124 lines (105 loc) · 2.73 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
module.exports = function(grunt){
'use strict';
grunt.initConfig({
//basic setting and info about plugins
pkg: grunt.file.readJSON('package.json'),
// Setting folder templates.
dirs: {
js: 'assets/js/', //<%= dirs.js %>
css: 'assets/css', //<%= dirs.css %>
sass: 'assets/scss', //<%= dirs.sass %>
},
//sass
sass:{
frontend:{
option:{
style:'expanded',
noCache: false,
},
files:{
'<%= dirs.css %>/style.css': ['<%= dirs.sass %>/main.scss'],
}
},
},
//auto prefix
postcss: {
options: {
map: true, // inline sourcemaps
safe: true,
processors: [
require('autoprefixer')({ overrideBrowserslist: 'last 3 versions' }), // add vendor prefixes
]
},
dist: {
src: '<%= dirs.css %>/style.css'
}
},
//css minify
cssmin: {
mainStyles: {
files:{
'<%= dirs.css %>/style.min.css': ' <%= dirs.css %>/style.css',
}
},
},
// Uglify JS.
uglify: {
forntend_js:{
options: {
sourceMap: true,
mangle: true
},
files:{
'<%= dirs.js %>/acmeticker.min.js': '<%= dirs.js %>/acmeticker.js',
'<%= dirs.js %>/jquery.min.js': '<%= dirs.js %>/jquery.js',
}
},
},
//grunt watch
watch: {
css: {
files: ['<%= dirs.sass %>/**/*.scss'],
tasks: [
'sass',
'cssmin',
'postcss',
'notify_hooks'
]
},
options: {
reload: true
}
},
// This is optional!
notify_hooks: {
options: {
enabled: true,
max_jshint_notifications: 2, // maximum number of notifications from jshint output
title: "Compile Complete", // defaults to the name in package.json, or will use project directory's name
success: true, // whether successful grunt executions should be notified automatically
duration: 1 // the duration of notification in seconds, for `notify-send only
}
},
});
//load plugins
// Load NPM tasks to be used here
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-contrib-sass' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks('grunt-notify');
grunt.registerTask('clean',
'Deletes the working folder and its contents', function () {
//grunt.config.requires('copyFiles.options.workingDirectory');
grunt.file.delete(grunt.config.get('clean.build.src'));
});
// Register tasks
grunt.registerTask('default', ['sass', 'cssmin', 'uglify','postcss'] );
grunt.registerTask('css', ['sass', 'cssmin', 'postcss'] );
grunt.registerTask('js', ['uglify'] );
grunt.task.run('notify_hooks');
};