forked from opensensorhub/osh-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
93 lines (90 loc) · 3.18 KB
/
webpack.config.js
File metadata and controls
93 lines (90 loc) · 3.18 KB
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
/* webpack.config.js */
let CopyWebpackPlugin = require('copy-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
var path = require('path');
const DIR_OUTPUT = path.resolve(__dirname, 'issues/umd/lib');
module.exports = {
// Tell Webpack which file kicks off our app.
entry: './source/core/OSH.js',
// Tell Weback to output our bundle to ./dist/bundle.js
output: {
filename: 'main.js',
library: 'OSH',
// libraryTarget: 'umd',
// globalObject: 'this',
path: DIR_OUTPUT,
// Needed to compile multiline strings in Cesium
sourcePrefix: '',
},
// externals: ['leaflet','cesium','chart.js', 'ol', 'ol-layerswitcher','nouislider','wnumb'],
amd: {
// Enable webpack-friendly use of require in Cesium
toUrlUndefined: true
},
resolve: {
modules: [
path.resolve(__dirname, 'node_modules')
],
fallback: {
fs: false,
path: false
}
},
optimization: {
minimize: false,
splitChunks: {
chunks: 'async',
minSize: 30000,
maxSize: 0,
minChunks: 1,
maxAsyncRequests: 6,
maxInitialRequests: 4,
automaticNameDelimiter: '~',
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true
}
}
}
},
// These rules tell Webpack how to process different module types.
// Remember, *everything* is a module in Webpack. That includes
// CSS, and (thanks to our loader) HTML.
module: {
rules: [
{
test: /\.(png|jpg|gif|svg)$/,
type: 'asset/resource',
generator: {
filename: '[name][ext]?[hash]'
}
}, {
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
}
]
},
mode: 'production',
plugins: [
new CleanWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{from: 'source/ext/resources/css', to: path.join(DIR_OUTPUT, 'css')},
{from: 'source/ext/resources/images', to: path.join(DIR_OUTPUT, 'images')},
{from: 'source/core/resources/css', to: path.join(DIR_OUTPUT, 'css')},
{from: 'source/core/resources/images', to: path.join(DIR_OUTPUT, 'images')},
{from: 'source/', to: path.join(DIR_OUTPUT, 'source')},
{from: 'libs/', to: path.join(DIR_OUTPUT, 'libs')},
{ from: path.resolve(__dirname, 'node_modules/cesium/Source/Workers'), to: path.join(DIR_OUTPUT, 'Workers') },
{ from: path.resolve(__dirname, 'node_modules/cesium/Source/Assets'), to: path.join(DIR_OUTPUT, 'Assets') },
{ from: path.resolve(__dirname, 'node_modules/cesium/Source/Widgets'), to: path.join(DIR_OUTPUT, 'Widgets') },
]
})
]
};