Skip to content

Commit 30dc4ab

Browse files
committed
Fix commit issue.
1 parent e000e6c commit 30dc4ab

File tree

2 files changed

+90
-75
lines changed

2 files changed

+90
-75
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
node_modules/
1+
node_modules/
2+
.jshintrc
3+
.idea
4+
/public
5+
.vscode

rollup.config.js

Lines changed: 85 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,108 @@
1-
import * as childx from "child_process";
2-
import fs from "fs";
1+
import * as childx from "child_process"; // Node.js child_process module
2+
import fs from "fs"; // Node.js file system module
33

44
import resolve from "rollup-plugin-node-resolve";
55
import commonjs from "rollup-plugin-commonjs";
6-
import { terser } from "rollup-plugin-terser";
6+
import {
7+
terser
8+
} from "rollup-plugin-terser";
79
import builtins from "builtin-modules";
810
import globals from "rollup-plugin-node-globals";
911
import builtins2 from "rollup-plugin-node-builtins";
1012
import json from "rollup-plugin-json";
1113
import replace from "rollup-plugin-replace";
1214

13-
var minify = false;
14-
var productionEnv = false;
15+
let minify = false;
16+
let productionEnv = false;
1517

1618
run("./src/renderer", "./renderer", minify);
1719
run("./src/main", "./main", minify);
1820

19-
var exp = [
20-
// main process (nodejs)
21-
{
22-
input: "./main_go.js",
23-
output: {
24-
file: "./main.js",
25-
format: "cjs",
26-
sourcemap: false
27-
},
28-
external: ["electron", ...builtins],
29-
plugins: [
30-
resolve(),
31-
commonjs({}),
32-
globals(),
33-
builtins2(),
34-
minify
35-
? terser({ ecma: 6 })
36-
: { name: "x", generateBundle: function() {} },
37-
deleteFile("./main_go.js"),
38-
deleteFile("./main_go.js.map")
39-
]
40-
},
41-
// renderer process (browser)
42-
{
43-
input: "./renderer_go.js",
44-
output: {
45-
file: "./renderer.js",
46-
format: "iife",
47-
sourcemap: false,
48-
name: "main"
49-
},
50-
external: ["electron"],
51-
plugins: [
52-
resolve({
53-
browser: true,
54-
preferBuiltins: true,
55-
dedupe: ["react", "react-dom"]
56-
}),
57-
replace({
58-
"process.env.NODE_ENV": JSON.stringify(
59-
productionEnv ? "production" : "development"
60-
)
61-
}),
62-
json(),
63-
commonjs({}),
64-
globals(),
65-
builtins2(),
66-
minify
67-
? terser({ ecma: 6 })
68-
: { name: "x", generateBundle: function() {} },
69-
deleteFile("./renderer_go.js"),
70-
deleteFile("./renderer_go.js.map")
71-
]
72-
}
21+
export default [
22+
// main process (nodejs) config
23+
{
24+
input: "./main_go.js",
25+
output: {
26+
file: "./main.js",
27+
format: "cjs",
28+
sourcemap: false
29+
},
30+
external: ["electron", ...builtins],
31+
plugins: [
32+
resolve(),
33+
commonjs({}),
34+
globals(),
35+
builtins2(),
36+
minify ?
37+
terser({
38+
ecma: 6
39+
}) :
40+
{
41+
name: "x",
42+
generateBundle: function () {}
43+
},
44+
deleteFile("./main_go.js"),
45+
deleteFile("./main_go.js.map")
46+
]
47+
},
48+
// renderer process (browser) config
49+
{
50+
input: "./renderer_go.js",
51+
output: {
52+
file: "./renderer.js",
53+
format: "iife",
54+
sourcemap: false,
55+
name: "main"
56+
},
57+
external: ["electron"],
58+
plugins: [
59+
resolve({
60+
browser: true,
61+
preferBuiltins: true,
62+
dedupe: ["react", "react-dom"]
63+
}),
64+
replace({
65+
"process.env.NODE_ENV": JSON.stringify(
66+
productionEnv ? "production" : "development"
67+
)
68+
}),
69+
json(),
70+
commonjs({}),
71+
globals(),
72+
builtins2(),
73+
minify ?
74+
terser({
75+
ecma: 6
76+
}) :
77+
{
78+
name: "x",
79+
generateBundle: function () {}
80+
},
81+
deleteFile("./renderer_go.js"),
82+
deleteFile("./renderer_go.js.map")
83+
]
84+
}
7385
];
7486

75-
export default exp;
76-
7787
function run(input, output, minify) {
78-
var path = "gopherjs build " + input;
79-
if (minify) {
80-
path = path + " -m ";
81-
}
88+
let path = "gopherjs build " + input;
89+
if (minify) {
90+
path = path + " -m ";
91+
}
8292

83-
output = output + "_go";
93+
output = output + "_go";
8494

85-
path = path + " -o " + output + ".js";
95+
path = path + " -o " + output + ".js";
8696

87-
childx.execSync(path);
97+
childx.execSync(path);
8898
}
8999

90100
function deleteFile(filePath) {
91-
return {
92-
name: "deleteFile",
93-
writeBundle: function() {
94-
fs.unlinkSync(filePath);
95-
}
96-
};
101+
return {
102+
name: "deleteFile",
103+
writeBundle: function () {
104+
fs.unlinkSync(filePath);
105+
}
106+
};
97107
}
108+

0 commit comments

Comments
 (0)