This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.js
113 lines (107 loc) · 3.12 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
101
102
103
104
105
106
107
108
109
110
111
112
113
const path = require("path");
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const merge = require("webpack-merge");
const isProduction = process.env.NODE_ENV === "production";
const bundleSuffix = isProduction ? ".min" : "";
/** @type{import("webpack").Configuration} */
const commonConfig = {
output: {
filename: `[name].bundle${bundleSuffix}.js`
},
resolve: {
extensions: [".webpack.js", ".web.ts", ".ts", ".tsx", ".web.js", ".js"]
},
devtool: isProduction ? "source-map" : "inline-source-map",
module: {
rules: [
{
test: /\.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
"sass-loader" // compiles Sass to CSS, using Node Sass by default
]
},
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
onlyCompileBundledFiles: true
}
},
{
test: /\.css$/,
loader: ["style-loader", "css-loader"]
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [
new CopyWebpackPlugin([
{
from: "node_modules/@here/harp-map-theme/resources",
to: ".",
toType: "dir"
},
require.resolve("three/build/three.min.js")
])
],
devServer: {
contentBase: path.join(__dirname, "dist")
},
mode: process.env.NODE_ENV || "development"
};
const mapEditorConfig = merge(commonConfig, {
entry: "./src/map-editor/index.tsx",
plugins: [
new HtmlWebpackPlugin({
template: "./src/map-editor/index.html"
})
]
});
const textEditorFrameConfig = merge(commonConfig, {
entry: {
textEditor: "./src/text-editor-frame/index.tsx"
},
plugins: [
new MonacoWebpackPlugin(),
new HtmlWebpackPlugin({
template: "./src/text-editor-frame/textEditor.html",
filename: "textEditor.html"
})
]
});
/** @type{import("webpack").Configuration} */
const decoderConfig = {
target: "webworker",
entry: {
decoder: "./src/decoder.ts"
},
output: {
filename: `[name].bundle${bundleSuffix}.js`
},
devtool: isProduction ? "source-map" : "inline-source-map",
resolve: {
extensions: [".ts", ".js"]
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
onlyCompileBundledFiles: true
}
}
]
},
mode: process.env.NODE_ENV || "development"
};
module.exports = [mapEditorConfig, textEditorFrameConfig, decoderConfig];