-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
86 lines (82 loc) · 2.73 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
module.exports = function (grunt) {
grunt.initConfig({
clean: ['dist/'], // Deletes the dist folder to start from a clean state
sass: { // Compiles SASS into CSS and copies them to the dist folder
dist: {
files: [{
expand: true,
cwd: 'src/styles',
src: ['*.sass'],
dest: 'dist/css/',
ext: '.css'
}]
}
},
browserify: { // Bundles the JS
options: {
browserifyOptions: {
debug: true
}
},
build: {
// cwd: 'src/', // DO NOT USE THIS OPTION HERE. IT WILL MESS UP THE BUILD
src: './src/scripts/index.js',
dest: 'dist/bundle.js'
}
},
connect: { // Starts a static file server
server: {
options: {
hostname: 'localhost',
port: 3000,
base: 'dist',
livereload: true
}
}
},
sync: {
// Keeps directories in sync and
// compared to grunt-contrib-copy, sync only copies newly changed files
// Refer https://www.webfoobar.com/node/78 for more
main: {
files: [
{ expand: true, cwd: 'src/', src: ['pages/*'], dest: 'dist' },
{ expand: true, cwd: 'src/', src: ['assets/**'], dest: 'dist' }
],
verbose: true // Display log messages when copying files
// pretend: true, // This option prevents any IO. dry run.
}
},
watch: {
options: {
livereload: true
},
js: {
files: ['src/scripts/*.js'],
tasks: ['browserify']
},
css: {
files: ['src/styles/*.sass'],
tasks: ['sass']
},
html: {
files: ['src/pages/*.html'],
tasks: ['sync']
},
assets: {
files: ['src/assets/**'],
tasks: ['sync']
}
},
});
// https://gruntjs.com/plugins
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-sync');
// Default task
grunt.registerTask('build', ['clean', 'sync', 'sass', 'browserify']);
grunt.registerTask('dev', ['build', 'connect', 'watch']);
};