-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
60 lines (57 loc) · 1.82 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
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackTagsPlugin = require("html-webpack-tags-plugin");
let entry;
let includeAssets = [];
if (process.env.WEBPACK_MODE === "test") {
entry = "./lib/tests/Api256Shim.test.ts";
includeAssets = [
{path: "https://unpkg.com/[email protected]/mocha.css", type: "css"},
{path: "https://www.chaijs.com/chai.js", type: "js", external: {packageName: "chai", variableName: "chai"}},
{path: "https://unpkg.com/[email protected]/mocha.js", type: "js", external: {packageName: "mocha", variableName: "mocha"}},
];
} else if (process.env.WEBPACK_MODE === "benchmark") {
entry = "./benchmark/index.ts";
includeAssets = [
{path: "https://unpkg.com/[email protected]/lodash.min.js", type: "js", external: {packageName: "lodash", variableName: "_"}},
{path: "https://unpkg.com/[email protected]/benchmark.js", type: "js", external: {packageName: "benchmark", variableName: "Benchmark"}},
];
}
module.exports = {
devServer: {
client: {
overlay: true,
},
},
entry,
output: {
filename: "[name].js",
},
mode: "development",
resolve: {
extensions: [".ts", ".js", ".wasm"],
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: ["ts-loader"],
},
],
},
experiments: {
syncWebAssembly: true,
},
plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackTagsPlugin({
tags: includeAssets,
append: false,
}),
new webpack.ProvidePlugin({
TextDecoder: ["text-encoding", "TextDecoder"],
TextEncoder: ["text-encoding", "TextEncoder"],
}),
],
};