forked from uwap/mqtt-control-map
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
61 lines (59 loc) · 1.78 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
const path = require('path');
const webpack = require('webpack');
const WebpackShellPlugin = require('webpack-shell-plugin-next');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const preBuildScripts = process.env.NO_FLOW == undefined ?
process.env.FLOW_PATH != undefined ? [process.env.FLOW_PATH] : ['flow']
: [];
const configPath = env => {
const filtered = Object.keys(env).filter((e) => !e.startsWith("WEBPACK"));
if (filtered.length < 1) {
throw "No config file was provided.";
}
return path.resolve(__dirname, `config/${filtered[0]}`);
};
module.exports = env => ({
entry: {
main: [configPath(env),
path.resolve(__dirname, 'src/index.jsx')]
},
resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"],
extensions: ['.js', '.jsx'],
alias: {
'lodash': 'lodash-es',
"leaflet": "leaflet/dist/leaflet-src.esm.js"
},
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name]-[chunkhash].js'
},
module: {
rules: [
// TODO: CSS follow imports and minify + sourcemap on production
{ test: /\.css$/, use: [ 'style-loader', 'css-loader' ] },
{ test: /\.(woff2?|eot|ttf|svg)$/, use: [ { loader: "file-loader", options: { esModule: false } } ] },
{ test: /\.js(x)?$/, use: ["babel-loader?cacheDirectory"] }
]
},
plugins: [
new CleanWebpackPlugin(),
new WebpackShellPlugin({
onBuildStart: {
scripts: preBuildScripts,
blocking: true,
parallel: false
}
}),
new HtmlWebpackPlugin({
title: 'Space Map',
template: 'index.ejs'
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
}),
]
});