-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
49 lines (46 loc) · 1.18 KB
/
webpack.config.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
var fs = require("fs");
var path = require("path");
var output = {
path: path.resolve(__dirname, "build"),
filename: "plugin.js",
libraryTarget: "umd",
};
module.exports = {
entry: "./ts/plugin.ts",
target: "node",
devtool: "inline-source-map",
output,
resolve: {
extensions: [".ts", ".js"], //resolve all the modules other than index.ts
},
module: {
rules: [
{
use: "ts-loader",
test: /\.ts?$/,
},
],
},
plugins: [
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap("AfterEmitPlugin", (compilation) => {
var filePath = (fileName) => {
return path.join(path.join(__dirname, fileName));
};
var getJson = (fileName) => {
return JSON.parse(fs.readFileSync(filePath(fileName)).toString());
};
var package = getJson("package.json");
var manifest = getJson("manifest.json");
manifest.version = package.version;
var manifestJson = JSON.stringify(manifest, null, 4);
fs.writeFileSync(
path.join(output.path, "manifest.json"),
manifestJson
);
});
},
},
],
};