-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.fx.js
47 lines (43 loc) · 1.41 KB
/
webpack.prod.fx.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
const path = require("path");
const package = require("./package.json");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ZipPlugin = require("zip-webpack-plugin");
const { merge } = require("webpack-merge");
const common = require("./webpack.common.js");
module.exports = merge(common, {
mode: "production",
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: "./src/manifestFx.json",
to: "./manifest.json"
}
]
}),
new ZipPlugin({
path: path.resolve(__dirname, "dist"),
filename: `timestamp_catcher_fx_v${package.version}_build_${getDateString()}.zip`,
// 如果要發佈到應用程式商店,請註解下面一行。
pathPrefix: "timestamp_catcher_fx"
})
],
output: {
filename: "./[name].js",
path: path.resolve(__dirname, "dist/timestamp_catcher_fx"),
}
});
// 來源:https://gist.github.com/ntuaha/f4b16ad377505a8519c7
function pad(v) {
return (v < 10) ? "0" + v : v
}
function getDateString() {
const d = new Date();
const year = d.getFullYear();
const month = pad(d.getMonth() + 1);
const day = pad(d.getDate());
const hour = pad(d.getHours());
const min = pad(d.getMinutes());
const sec = pad(d.getSeconds());
return `${year}${month}${day}${hour}${min}${sec}`;
}