forked from reggie3/react-native-webview-leaflet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
95 lines (93 loc) · 2.49 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
// the path(s) that should be cleaned
let pathsToClean = [
'assets/dist/*.*',
'assets/dist/main.bundle.js.map',
'build/*.*',
];
module.exports = {
mode: 'development',
devtool: 'source-map',
entry: {
main: './web/index.js',
},
output: {
path: path.join(__dirname, './build'),
filename: '[name].bundle.js',
},
module: {
rules: [
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
{
loader: 'file-loader',
options: {
name(file) {
return 'images/[name].[ext]';
},
},
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.js$/,
include: [path.resolve(__dirname, 'web')],
exclude: /(node_modules|bower_components)/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'env',
{
targets: {
browsers: ['last 2 versions', 'safari >= 7'],
},
},
],
'react',
'stage-2',
],
plugins: ['babel-plugin-transform-object-rest-spread'],
},
},
],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.scss', '.css'],
alias: {
leaflet_search:
__dirname + '/node_modules/leaflet-search/dist/leaflet-search.min.js',
leaflet_search_css:
__dirname + '/node_modules/leaflet-search/dist/leaflet-search.min.css',
marker_cluster_css:
__dirname +
'/node_modules/leaflet.markercluster/dist/MarkerCluster.css',
marker_cluster_default_css:
__dirname +
'/node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css',
leaflet_css: __dirname + '/node_modules/leaflet/dist/leaflet.css',
},
},
plugins: [
new CleanWebpackPlugin(pathsToClean),
new HtmlWebpackPlugin({
inlineSource: '.(js|css)$', // embed all javascript and css inline
template: './web/index.html',
inject: 'body',
}),
new HtmlWebpackInlineSourcePlugin(),
],
};