-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGruntfile.js
98 lines (92 loc) · 1.71 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
var path = require('path');
var node_modules = path.resolve(__dirname,'node_modules');
var reactPath = path.resolve(node_modules, 'react/dist/react-with-addons.js');
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// Copy source files to the build directory
copy: {
html: {
expand: true,
cwd: 'source/',
src: '**/*.html',
dest: 'build/'
},
images: {
expand: true,
cwd: 'source/',
src: 'images/**/*',
dest: 'build/'
}
},
// Webpack
webpack:{
all: {
entry: "./source/index.js",
resolve: {
alias: {
'react': reactPath
}
},
output: {
path: "build",
filename: "index.js"
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /buffer/
},
{
test: /\.glsl$/,
loader: 'raw',
exclude: /node_modules/
},
{
test: /\.css$/,
loader: 'style!css'
},
{
test: /\.scss$/,
loader: 'style!css!sass'
}
],
noParse: reactPath
},
devtool: "source-map"
}
},
// A basic static web server with livereload
connect: {
dev: {
options: {
port: 8080,
base: ['build'],
hostname: '*',
livereload: true
}
}
},
watch: {
options: {
livereload: true
},
html: {
files: ['source/**/*.html'],
tasks: ['copy:html']
},
webpack: {
files: ['source/**/*.{js,glsl,css,scss}'],
tasks: ['webpack']
},
images: {
files: ['source/images/**/*'],
tasks: ['copy:images']
}
}
});
grunt.registerTask('build',['copy','webpack','connect','watch']);
grunt.registerTask('default',['build']);
};