-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
83 lines (79 loc) · 2.3 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
const path = require("path");
const glob = require("glob");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const dir = path.resolve(__dirname);
const entries = glob.sync("./examples/src/*.ts").reduce(
(entries, file) =>
Object.assign(entries, {
[file.match(/^.*\/([^\/]*)\.ts$/)[1]]: file,
}),
{}
);
const harpMapThemePath = path.dirname(require.resolve("@here/harp-map-theme/package.json"));
const leafletDist = path.dirname(require.resolve("leaflet/dist/leaflet.js"));
module.exports = {
context: dir,
mode: "development",
entry: entries,
output: {
filename: "build/[name].bundle.js",
path: path.resolve(__dirname, "./examples"),
},
externals: {
three: "THREE",
leaflet: "L",
},
resolve: {
extensions: [".ts", ".tsx", ".webpack.js", ".web.ts", ".web.js", ".js"],
alias: {
"harp-leaflet$": path.resolve(__dirname, "./src/index.ts"),
"harp-leaflet": path.resolve(__dirname, "./src/"),
},
},
module: {
rules: [{ test: /\.tsx?$/, loader: "ts-loader" }],
},
plugins: [
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, "./build/harp-leaflet.js"),
to: "vendor/harp-leaflet.js",
toType: "file",
force: true,
},
{
from: require.resolve("@here/harp.gl/dist/harp.min.js"),
to: "vendor/",
},
{
from: require.resolve("@here/harp.gl/dist/harp-decoders.min.js"),
to: "vendor/",
},
{
from: require.resolve("three/build/three.min.js"),
to: "vendor/",
},
{
from: path.join(harpMapThemePath, "resources/"),
to: "resources/harp-map-theme",
toType: "dir",
},
{
from: leafletDist,
to: "vendor/",
},
]),
],
devServer: {
contentBase: path.resolve(__dirname, "examples"),
open: true,
},
stats: {
all: false,
timings: true,
exclude: "/resources/",
errors: true,
entrypoints: true,
warnings: true,
},
};