-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
121 lines (118 loc) · 4.28 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
114
115
116
117
118
119
120
121
const path = require("path");
const nodePolyfillWebpackPlugin = require('node-polyfill-webpack-plugin')
const HtmlTagsPlugin = require("html-webpack-tags-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const {DefinePlugin} = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const PROCESS_BASE_PATH = process.cwd();
// Cesium deps
const cesiumSource = 'node_modules/cesium/Build/Cesium';
const cesiumBaseUrl = "cesiumStatic";
module.exports = {
entry: "./src/index.tsx",
output: {
filename: "main.js",
path: path.resolve(__dirname, "build"),
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "public", "index.html"),
favicon: path.join(__dirname, "public/images", "opensensorhub.png")
}),
new DefinePlugin({
BASE_URL: JSON.stringify('/'),
// Define relative base path in cesium for loading assets
// CESIUM_BASE_URL: JSON.stringify('cesium')
CESIUM_BASE_URL: JSON.stringify(cesiumBaseUrl)
}),
new CopyWebpackPlugin({
patterns: [
// {from: "node_modules/cesium/Build/Cesium", to: "cesium"},
{from: path.resolve(__dirname, 'src/assets'), to: 'assets'},
{from: path.resolve(__dirname, 'src/icons'), to: 'icons'},
{ from: path.resolve(__dirname,'images'), to: 'images', noErrorOnMissing: true},
{ from: path.join(PROCESS_BASE_PATH+'/'+cesiumSource, 'ThirdParty'), to: `${cesiumBaseUrl}/ThirdParty`, force:true },
{ from: path.join(PROCESS_BASE_PATH+'/'+cesiumSource, 'Workers'), to: `${cesiumBaseUrl}/Workers`, force:true },
{ from: path.join(PROCESS_BASE_PATH+'/'+cesiumSource, 'Assets'), to: `${cesiumBaseUrl}/Assets`, force:true },
{ from: path.join(PROCESS_BASE_PATH+'/'+cesiumSource, 'Widgets'), to: `${cesiumBaseUrl}/Widgets`, force:true }
],
}),
// new HtmlTagsPlugin({
// append: false,
// tags: ["cesium/Build/Cesium/Widgets/widgets.css", "cesium/Build/Cesium/Cesium.js"],
// }),
new nodePolyfillWebpackPlugin(),
],
devServer: {
client: {
overlay: false
},
static: {
directory: path.join(__dirname, "build"),
},
port: 3000,
},
module: {
// exclude node_modules
rules: [
{
test: /\.(js|jsx|tsx)$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader',]
},
{
test: /\.(glb|gltf)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
}
}
},
{
test: /\.(mp4)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
}
}
},
{
test: /\.(png|svg|jpg|gif)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
}
},
},
{
test: /\.worker\.js$/,
use: {loader: 'worker-loader', options: {filename: 'Worker.[chunkhash].js'}}
},
],
},
// pass all js files through Babel
resolve: {
modules: [
path.resolve(__dirname, 'node_modules'),
],
extensions: ["*", ".js", ".jsx", ".tsx"], // <-- added `.jsx` here
fallback: {
"url": require.resolve("url/"),
"zlib": require.resolve("browserify-zlib"),
"https": require.resolve("https-browserify"),
"http": require.resolve("stream-http"),
"buffer": require.resolve("buffer/"),
"assert": require.resolve("assert/"),
"util": require.resolve("util/"),
"stream": require.resolve("stream-browserify"),
fs: false
}
}
};