forked from OpenGeoscience/geojs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.base.config.js
127 lines (123 loc) · 2.74 KB
/
webpack.base.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
122
123
124
125
126
127
const path = require('path');
var exec = require('child_process').execSync;
var webpack = require('webpack');
var TerserPlugin = require('terser-webpack-plugin');
var sha = '';
try {
sha = exec('git rev-parse HEAD', {cwd: __dirname}).toString().trim();
} catch (e) {
console.warn('Could not determine git hash.');
}
var define_plugin = new webpack.DefinePlugin({
GEO_SHA: JSON.stringify(sha),
GEO_VERSION: JSON.stringify(require('./package.json').version)
});
module.exports = {
mode: 'production',
performance: {hints: false},
cache: true,
devtool: 'source-map',
context: path.join(__dirname, 'src'),
output: {
path: path.resolve(__dirname, 'dist', 'built'),
publicPath: 'dist/built',
filename: '[name].js',
library: 'geo',
libraryTarget: 'umd'
},
resolve: {
alias: {
jquery: 'jquery/dist/jquery',
proj4: 'proj4/lib',
vgl: 'vgl/vgl.js',
d3: 'd3/d3.js',
hammerjs: '@egjs/hammerjs/dist/hammer.js',
mousetrap: 'mousetrap/mousetrap.js'
}
},
target: ['web', 'es5'],
plugins: [
define_plugin
],
optimization: {
minimizer: [
new TerserPlugin({
include: /\.min\.js$/,
extractComments: false,
parallel: true
})
]
},
module: {
rules: [{
test: /\.js$/,
include: path.resolve('src'),
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: [['@babel/preset-env', {
targets: 'defaults, PhantomJS 2.1'
}]]
}
}]
}, {
test: /\.js$/,
include: [
path.resolve('tests'),
path.resolve('examples'),
path.resolve('tutorials')
],
use: [{
loader: 'babel-loader',
options: {
cacheDirectory: true
}
}]
}, {
test: /\.styl$/,
use: [
'style-loader',
'css-loader',
'stylus-loader'
]
}, {
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
}, {
test: /\.(glsl|vs|fs|vert|frag)$/,
use: [{
loader: 'shader-loader',
options: {
glsl: { chunkPath: 'src/webgl' }
}
}]
}, {
// vgl expects jQuery, gl-vec3/4, gl-mat4 to be in the global name space
test: /vgl\.js$/,
use: [{
loader: 'expose-loader',
options: {
exposes: {
globalName: 'vgl',
override: true
}
}
}, {
loader: 'imports-loader',
options: {
type: 'commonjs',
imports: [
'single gl-mat4 mat4',
'single gl-vec4 vec4',
'single gl-vec3 vec3',
'single jquery $'
]
}
}]
}]
}
};