forked from TaDaa/react-poppy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
37 lines (34 loc) · 984 Bytes
/
build.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
var babel = require('babel-core'),
fs = require('fs');
copy ("index.js") ("poppy.css");
transform_jsx ("container.js") ("poppy.js")
function copy (file) {
fs.readFile("libs/"+file,function (err,data) {
fs.writeFile("dist/"+file,data,function (err,data) {
if (err) {
console.error(err.toString());
} else {
console.error("done writing " + file);
}
});
});
return copy;
}
function transform_jsx (file) {
babel.transformFile("libs/"+file,{
'presets' : ['react']
},function (err,code) {
if (err) {
console.error(err.toString());
} else {
fs.writeFile("dist/"+file,code.code,function (err) {
if (err) {
console.error(err.toString());
} else {
console.error("done writing " + file);
}
});
}
});
return transform_jsx;
}