-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
41 lines (38 loc) · 1.26 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
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-undef */
const path = require("path");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const nodeModules = path.resolve(__dirname, "node_modules");
const sourceDir = path.resolve(__dirname, "src");
const distDir = path.resolve(__dirname, "dist");
module.exports = (_, argv) => {
const isProduction = argv.mode === "production";
return {
entry: path.resolve(sourceDir, "canvas", isProduction ? "index.ts" : "dev.ts"),
devtool: !isProduction && "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: [nodeModules],
},
],
},
resolve: {
plugins: [new TsconfigPathsPlugin()],
extensions: [".tsx", ".ts", ".js"],
modules: [nodeModules],
},
output: {
filename: isProduction ? "production.js" : "dev.js",
path: distDir,
library: "Piero",
libraryTarget: "var", // TODO: reconsider in production!
},
devServer: {
static: distDir,
port: 9000,
},
};
};