-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
121 lines (113 loc) · 2.88 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
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
webpack: {
app: webpackConfig,
},
express: {
options: {},
server: {
options: {
script: '<%= pkg.folders.server %>/server.js',
}
},
},
less : {
dev: {
options: {
rootpath: '.',
compress: false,
yuicompress: false,
optimization: 0,
sourceMap: false
},
files: [{
'./public/css/app.css': [
'<%= pkg.folders.assets %>/less/bootstrap.less'
]
}]
},
},
watch: {
server: {
options: {
nospawn: true, //Without this option specified express won't be reloaded
atBegin: true,
},
// triggering livereload when the files are updated
// allows livereload to not do a full page refresh
files: ['<%= pkg.folders.server %>/**/*.js'],
tasks: ['express:server']
},
less: {
files: ['<%= pkg.folders.assets %>/less/**/*.less'],
tasks: ['less:dev']
},
webpack: {
files: ['<%= pkg.folders.app %>/**/*.js'],
tasks: ['webpack:dev']
}
},
// Wiredep for inject bower dependencies
// into app/app/index.html
// it take cares about the server root replacing the
// absolute path to a custom one
wiredep: {
task: {
cwd: '',
src: ['<%= pkg.folders.views %>/main.html'],
fileTypes: {
html: {
block: /(([ \t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
detect: {
js: /<script.*src=['"]([^'"]+)/gi,
css: /<link.*href=['"]([^'"]+)/gi
},
replace: {
js: (path) => {
path = _getWiredepPath(path);
return '<script src="' + path + '"></script>';
},
css: (path) => {
path = _getWiredepPath(path);
return '<link rel="stylesheet" href="' + path + '"/>'
}
}
}
}
}
},
parallel: {
dev: {
options: {
stream: true
},
tasks: [
{
grunt: true,
args: ['wiredep']
},
{
grunt: true,
args: ['watch:server']
},
{
grunt: true,
args: ['less:dev', 'watch:less']
},
{
grunt: true,
args: ['webpack:app', 'watch:webpack']
}
]
},
}
});
grunt.registerTask('default', ['parallel:dev']);
function _getWiredepPath(path) {
return path.replace('../public/', '');
}
};