forked from BarnabasRobotics/barnabas-blocks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
100 lines (98 loc) · 2.52 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import path from "path"
import HtmlWebpackPlugin from "html-webpack-plugin"
import MiniCssExtractPlugin from "mini-css-extract-plugin"
import webpack from "webpack"
const { ProvidePlugin } = webpack
export default {
entry: {
index: {
import: "./web/index.js",
dependOn: [
"blockly",
"blocks",
"generators",
],
},
blockly: "blockly",
blocks: {
import: "./web/blocks/blocks.ts",
dependOn: [
"blockly",
],
},
generators: {
import: "./web/generator/arduinoGenerator.ts",
dependOn: [
"blockly",
],
},
img2hex: {
import: "./web/img2hex.js",
},
},
devtool: "inline-source-map",
mode: "production",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
include: /web|common/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.m?js$/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.(html)$/,
use: "html-loader",
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.(css)$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
fallback: {
os: false,
util: import.meta.resolve("util"),
stream: false,
},
},
plugins: [
new ProvidePlugin({
// eslint-disable-next-line @stylistic/quote-props
"Buffer": ["buffer", "Buffer"],
process: "process/browser.js",
}),
new MiniCssExtractPlugin(),
new HtmlWebpackPlugin({
template: "web/index.html",
excludeChunks: ["img2hex"],
}),
new HtmlWebpackPlugin({
filename: "img2hex.html",
template: "web/img2hex.html",
chunks: ["img2hex"],
}),
],
output: {
filename: "[name].bundle.js",
path: path.resolve(import.meta.dirname, "dist"),
clean: true,
},
}