forked from OpenGeoscience/geojs
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.base.config.js
109 lines (105 loc) · 2.36 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
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',
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'), ],
exclude: [
/node_modules\/(?!(kdbush|earcut)\/).*/,
path.resolve('tests')
],
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,
presets: [['@babel/preset-env', {
targets: 'defaults, PhantomJS 2.1'
}]]
}
}]
}, {
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' }
}
}]
}]
}
};