-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
107 lines (98 loc) · 2 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
#!/usr/bin/env node
'use strict'
const pkg = require('./package.json')
const plugins = [
'grunt-contrib-clean',
'grunt-contrib-connect',
'grunt-contrib-cssmin',
'grunt-contrib-htmlmin',
'grunt-contrib-watch',
'grunt-replace',
]
const clean = {
cssmin: ['public/sinanbolel.min.css'],
release: ['public/release/*.js'],
}
const connect = {
client: {
options: {
base: 'public',
livereload: true,
open: {
appName: 'Google Chrome',
target: 'http://localhost:3000',
},
port: 3000,
},
},
}
const cssmin = {
options: {
keepSpecialComments: false,
shorthandCompacting: true,
sourceMap: false,
},
target: {
files: {
'public/<%= pkg.name %>.min.css': [
'src/css/base.css',
'src/css/icons.css',
'src/css/buttons.css',
'src/css/tooltip.css',
]
},
},
}
const htmlmin = {
dist: {
options: {
removeComments: true,
collapseWhitespace: true,
},
files: { 'public/index.html': 'src/index.html', }
}
}
const watch = {
src: {
files: ['src/css/*.css', 'src/index.html'],
tasks:['cssmin', 'htmlmin', 'replace'],
},
html: {
files: ['public/index.html'],
options: {
livereload: true,
},
},
}
module.exports = ({
initConfig,
loadNpmTasks,
option,
registerTask,
}) => {
const replace = {
dist: {
options: {
patterns: [{
match: '/*__MINIFIED_CSS__*/',
replacement: '<%= grunt.file.read("public/sinanbolel.min.css") %>',
}],
prefix: '',
usePrefix: false,
},
files: [
{
dest: 'public/',
expand: true,
flatten: true,
src: ['public/index.html'],
}
]
}
}
initConfig({ clean, connect, cssmin, htmlmin, pkg, replace, watch })
plugins.forEach(loadNpmTasks)
registerTask('serve', ['connect', 'watch'])
registerTask('build', ['cssmin', 'htmlmin', 'replace'])
registerTask('default', ['build', 'serve'])
}