-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
96 lines (87 loc) · 2.33 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
const {resolve, join} = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const rootDir = join(__dirname, '..');
const demoDir = join(__dirname, './');
const demoSources = join(demoDir, 'src');
// Otherwise modules imported from outside this directory does not compile
// Seems to be a Babel bug
// https://github.com/babel/babel-loader/issues/149#issuecomment-191991686
const BABEL_CONFIG = {
presets: [
'es2015',
'react',
'stage-0'
].map(function configMap(name) {
return require.resolve(`babel-preset-${name}`);
}),
plugins: [
'transform-decorators-legacy'
].map(function configMap(name) {
return require.resolve(`babel-plugin-${name}`);
})
};
module.exports = {
entry: ['./src/main'],
module: {
rules: [{
test: /\.js$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: BABEL_CONFIG
}]
}, {
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader', 'autoprefixer-loader']
}, {
test: /\.csv$/,
loader: 'csv-loader',
options: {
dynamicTyping: true,
header: true,
skipEmptyLines: true
}
}, {
test: /\.(eot|svg|ttf|woff|woff2|gif|jpe?g|png)$/,
loader: 'url-loader'
}, {
test: /\.glsl$/,
loader: 'raw-loader',
include: demoSources,
enforce: 'post'
}],
// Uglify seems to be incompatible with mapbox
// https://github.com/mapbox/mapbox-gl-js/issues/4359#issuecomment-288001933
noParse: /(mapbox-gl)\.js$/
},
resolve: {
modules: [resolve(rootDir, 'node_modules'), resolve(demoDir, 'node_modules')],
alias: {
// used by Mapbox
webworkify: 'webworkify-webpack-dropin',
// From mapbox-gl-js README. Required for non-browserify bundlers (e.g. webpack):
'mapbox-gl$': resolve('./node_modules/mapbox-gl/dist/mapbox-gl.js')
}
},
node: {
fs: 'empty'
},
// Optional: Enables reading mapbox token from environment variable
plugins: [
new webpack.EnvironmentPlugin(['MAPBOX_ACCESS_TOKEN', 'MapboxAccessToken']),
new CopyWebpackPlugin([
{
from: './docs',
to: 'docs'
},
{
from: './demos/data',
to: 'data'
},
{
from: './src/static'
}
])
]
};