forked from davenquinn/cesium-martini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
69 lines (67 loc) · 1.99 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
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const DotenvPlugin = require("dotenv-webpack");
const { DefinePlugin } = require("webpack");
const path = require("path");
const cesiumSource = "node_modules/cesium/Source";
const cesiumWorkers = "../Build/CesiumUnminified/Workers";
module.exports = {
// Enable sourcemaps for debugging webpack's output.
devtool: "source-map",
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
// CesiumJS module name
cesiumSource: path.resolve(__dirname, cesiumSource)
}
},
module: {
unknownContextCritical: false,
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.(png|svg)$/,
use: ["file-loader"]
},
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
},
// https://github.com/CesiumGS/cesium/issues/9790#issuecomment-943773870
{
test: /.js$/,
include: path.resolve(__dirname, 'node_modules/cesium/Source'),
use: { loader: require.resolve('@open-wc/webpack-import-meta-loader') }
},
]
},
node: {
fs: "empty"
},
amd: {
// Enable webpack-friendly use of require in Cesium
toUrlUndefined: true
},
plugins: [
new HtmlWebpackPlugin({ title: "Mapbox / Cesium Terrain" }),
new CopyPlugin([
{ from: path.join(cesiumSource, cesiumWorkers), to: "Workers" }
]),
new CopyPlugin([{ from: path.join(cesiumSource, "Assets"), to: "Assets" }]),
new CopyPlugin([
{ from: path.join(cesiumSource, "Widgets"), to: "Widgets" }
]),
new DotenvPlugin(),
new DefinePlugin({
// Define relative base path in cesium for loading assets
CESIUM_BASE_URL: JSON.stringify("/")
})
]
};