-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
133 lines (129 loc) · 3.46 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) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
grunt.loadNpmTasks('grunt-browser-sync');
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-contrib-jshint');
const path = require('path');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
project: {
dev: 'server',
dist: 'dist',
build: '<%= grunt.template.today("yyyymmdd") %>'
},
// local server
php: {
server: {
options: {
host: 'localhost',
port: process.env.PORT || '8010',
base: '<%= project.dev %>/public',
router:'<%= project.dev %>/.htrouter.php',
env:{
APPLICATION_ENV : 'development'
}
}
}
},
browserSync: {
dev: {
bsFiles: {
src: ['server/**/*.php', '<%= project.dev %>/public/js/**/*.js']
},
options: {
proxy: '127.0.0.1:8010', //our PHP server
port: 8080, // our new port
open: true,
watchTask: true
}
}
},
// watch for file changes
watch: {
// styles: {
// files: ['<%= project.dev %>/less/**/*.less'],
// tasks: ['less:dev'],
// options: {
// livereload: true
// }
// },
scripts: {
files: ['<%= project.dev %>/public/src/js/**/*.js', 'Gruntfile.js'],
tasks: ['webpack:build', 'jshint:dev'], // !important
options: {
livereload: true,
reload: true
}
}
},
// compile less
// less: {
// dev: {
// files: {
// '<%= project.dev %>/css/style.css': ['<%= project.dev %>/less/style.less']
// }
// }
// },
// lint js
jshint : {
dev: ['<%= project.dev %>/public/src/js/**/*.js', '<%= project.dev %>/js/index.js'],
options: {
reporter: require('jshint-stylish')
}
},
// copy
// copy: {
// setup: {
// expand: true,
// cwd: '<%= project.dev %>/public/vendor/font-awesome/fonts/',
// src: ['*.{otf,ttf,svg,eot,woff,woff2}'],
// dest: '<%= project.dev %>/public/fonts/'
// }
// },
// webpack !pay attention to this task!
webpack: {
build: {
entry: ['./server/public/src/js/index.js'],
output: {
path: __dirname +'/server/public/js/',
filename: 'bundle.js'
},
resolve: {
// options for resolving module requests
// (does not apply to resolving to loaders)
modules: [
"node_modules",
path.resolve(__dirname, "/server/public/src/js")
],
// directories where to look for modules
extensions: [".js", ".json", ".jsx", ".css"],
},
stats: {
colors: true,
modules: true,
reasons: true
},
storeStatsTo: 'webpackStats',
progress: true,
failOnError: true,
watch: true,
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader", query: {
presets: ['es2015', 'react']
} }
]
}
}
}
});
// Tasks
grunt.registerTask('default', ['develop']);
grunt.registerTask('develop', [
'php:server',
'browserSync',
'watch'
]);
grunt.registerTask('setup', ['copy:setup']);
};