-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
44 lines (43 loc) · 1.95 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
const path = require("path");
/**
* @type {import("webpack").Configuration}
*/
module.exports = {
//tell webpack where to look for source files
context: path.resolve(__dirname, "src"),
entry: {
//each entrypoint results in an output file
//so this results in an output file called 'main.js' which is built from src/index.ts
"main": "./index.ts"
},
output: {
path: path.resolve(__dirname, "dist"),
// library means that the exports from the entry file can be accessed from outside, in this case from the global scope as window.TestApp
library: { type: "umd", name: "TestApp" }
},
devtool: false,
mode: "development",
// prevent webpack from bundling these imports (alt1 libs can use them when running in nodejs)
externals: [
"sharp",
"canvas",
"electron/common"
],
resolve: {
extensions: [".wasm", ".tsx", ".ts", ".mjs", ".jsx", ".js"]
},
module: {
// The rules section tells webpack what to do with different file types when you import them from js/ts
rules: [
{ test: /\.tsx?$/, loader: "ts-loader" },
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
{ test: /\.scss$/, use: ["style-loader", "css-loader", "sass-loader"] },
// type:"asset" means that webpack copies the file and gives you an url to them when you import them from js
{ test: /\.(png|jpg|jpeg|gif|webp)$/, type: "asset/resource", generator: { filename: "[base]" } },
{ test: /\.(html|json)$/, type: "asset/resource", generator: { filename: "[base]" } },
// file types useful for writing alt1 apps, make sure these two loader come after any other json or png loaders, otherwise they will be ignored
{ test: /\.data\.png$/, loader: "alt1/imagedata-loader", type: "javascript/auto" },
{ test: /\.fontmeta.json/, loader: "alt1/font-loader" }
]
}
}