forked from YahooArchive/flux-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
76 lines (72 loc) · 2.52 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
var webpack = require('webpack');
module.exports = function (grunt) {
grunt.initConfig({
clean: ['./' + grunt.option('taskName') + '/build'],
concurrent: {
dev: ['nodemon:dev', 'webpack:dev'],
options: {
logConcurrentOutput: true
}
},
copy: {
todo: {
files: [{
expand: true,
cwd: 'todo/assets/todomvc-common/',
src: ['*.*'],
dest: 'todo/build/'
}, {
expand: true,
cwd: 'todo/assets/',
src: ['styles.css'],
dest: 'todo/build/'
}]
}
},
nodemon: {
dev: {
script: './' + grunt.option('taskName') + '/server.js',
options: {
ignore: ['build/**'],
ext: 'js,jsx'
}
}
},
webpack: {
dev: {
resolve: {
extensions: ['', '.js', '.jsx']
},
entry: './' + grunt.option('taskName') + '/client.js',
output: {
path: './' + grunt.option('taskName') + '/build/js',
filename: 'client.js'
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.(js|jsx)$/, exclude: /node_modules/, loader: require.resolve('babel-loader') }
]
},
plugins: [
// Protects against multiple React installs when npm linking
new webpack.NormalModuleReplacementPlugin(/^react?$/, require.resolve('react')),
new webpack.NormalModuleReplacementPlugin(/^react(\/addons)?$/, require.resolve('react/addons'))
],
stats: {
colors: true
},
devtool: 'source-map',
watch: true,
keepalive: true
}
}
});
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-webpack');
grunt.registerTask('default', ['clean', 'concurrent:dev']);
grunt.registerTask('todo', ['clean', 'copy:todo', 'concurrent:dev']);
};