forked from OpenGeoscience/geojs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.base.config.js
152 lines (148 loc) · 3.46 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
var path = require('path');
var webpack = require('webpack');
var exec = require('child_process').execSync;
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
var sha = '';
if (!exec) {
console.warn('Node 0.12 or greater is required for detecting the git hash.');
}
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 = {
/* webpack 4
mode: 'production',
*/
performance: {hints: false},
cache: true,
devtool: 'source-map',
context: path.join(__dirname, 'src'),
output: {
path: path.join(__dirname, 'dist', 'built'),
publicPath: 'dist/built',
filename: '[name].js',
library: 'geo',
libraryTarget: 'umd'
},
resolve: {
alias: {
jquery: 'jquery/dist/jquery',
kdbush: 'kdbush/kdbush.js',
proj4: 'proj4/lib',
vgl: 'vgl/vgl.js',
d3: 'd3/d3.js',
hammerjs: 'hammerjs/hammer.js',
mousetrap: 'mousetrap/mousetrap.js'
}
},
plugins: [
/* webpack 3 */
new UglifyJsPlugin({
include: /(bundle|\.min)\.js$/,
parallel: true,
uglifyOptions: {
compress: true,
comments: /@(license|copyright)/
},
sourceMap: true
}),
/* end webpack 3 */
define_plugin
],
/* webpack 4
optimization: {
minimizer: [
new UglifyJsPlugin({
include: /\.min\.js$/,
parallel: true,
uglifyOptions: {
compress: true,
comments: /@(license|copyright)/
},
sourceMap: true
})
]
},
*/
module: {
rules: [{
/* The first rule only includes src/*.js so that it can conveniently be
* modified for istanbul instrumentation */
test: /\.js$/,
include: path.resolve('src'),
exclude: path.resolve('src/polyfills.js'),
use: [{
loader: 'babel-loader',
options: {
plugins: [require('babel-plugin-transform-object-rest-spread')],
presets: [[
'env', {
targets: {
browsers: ['defaults'],
uglify: true
},
useBuiltIns: 'usage'
}
]],
cacheDirectory: true
}
}]
}, {
test: /\.js$/,
include: [
path.resolve('tests'),
path.resolve('examples'),
path.resolve('tutorials')
],
use: [{
loader: 'babel-loader',
options: {
plugins: [require('babel-plugin-transform-object-rest-spread')],
presets: [[
'env', {
targets: {
browsers: ['defaults'],
uglify: true
},
useBuiltIns: 'usage'
}
]],
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' }
}
}]
}, {
test: /vgl\.js$/,
use: [
'expose-loader?vgl',
'imports-loader?mat4=gl-mat4,vec4=gl-vec4,vec3=gl-vec3,$=jquery'
]
}]
}
};