-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.js
61 lines (57 loc) · 1.31 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
50
51
52
53
54
55
56
57
58
59
60
61
const path = require("path");
const fs = require("fs");
const Dotenv = require("dotenv-webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
var nodeModules = {};
var pluginModules = [
new CopyWebpackPlugin([
{ from: "src/keycloak.json", to: path.resolve(__dirname, "dist") },
{ from: "src/data", to: `${path.resolve(__dirname, "dist")}/data` }
])
];
if (process.env.NODE_ENV === "Development") {
pluginModules.push(new Dotenv());
} else {
pluginModules.push(new CleanWebpackPlugin());
}
fs.readdirSync("node_modules")
.filter(function(x) {
return [".bin"].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = "commonjs " + mod;
});
module.exports = {
entry: "./src/app.ts",
target: "node",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader"
},
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: {
minimize: true,
attrs: false
}
}
]
}
]
},
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"]
},
plugins: pluginModules,
output: {
filename: "index.js",
path: path.resolve(__dirname, "dist")
},
externals: nodeModules
};