-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathwebpack.config.ts
More file actions
44 lines (40 loc) · 1.11 KB
/
webpack.config.ts
File metadata and controls
44 lines (40 loc) · 1.11 KB
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
import * as path from "path";
import * as webpack from "webpack";
import * as nodeBuiltins from "builtin-modules";
const DIST_DIR = path.join(__dirname, "dist");
const NodemonPlugin = require('nodemon-webpack-plugin');
const externals: webpack.Configuration["externals"] = ([] as string[])
.concat(nodeBuiltins)
.reduce((externalsMap, moduleName) => {
externalsMap[moduleName] = moduleName;
return externalsMap;
}, {} as { [k: string]: string });
const config: webpack.Configuration = {
mode: "production",
target: "node",
entry: {
api: "./src/api.ts",
},
output: {
path: DIST_DIR,
filename: "[name].js",
libraryTarget: "umd",
},
resolve: {
extensions: [".mjs", ".ts", ".js"],
},
module: {
rules: [
{ test: /\.ts$/, loader: "ts-loader" },
// See https://github.com/apollographql/apollo-link-state/issues/302
{ test: /\.mjs$/, include: /node_modules/, type: "javascript/auto" },
],
// https://github.com/webpack/webpack/issues/3078
noParse: /iconv-loader\.js/,
},
plugins: [
new NodemonPlugin(),
],
externals,
};
export default config;