-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathwebpack.config.babel.js
179 lines (166 loc) · 4.56 KB
/
webpack.config.babel.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import path from "path"
import webpack from "webpack"
import HTMLPlugin from 'html-webpack-plugin'
import { APP_STAGES } from "./src/constants/App"
let plugins = [];
const config = {
mode: "development",
entry: {
app: ['babel-polyfill', path.join(__dirname, "src/index.js")],
businesscard_widget: ['babel-polyfill', path.join(__dirname, "src/widgets/businesscard/index.js")],
map_widget: ['babel-polyfill', path.join(__dirname, "src/widgets/map/index.js")],
mapAndEntryList_widget: ['babel-polyfill', path.join(__dirname, "src/widgets/mapAndEntryList/index.js")]
},
output: {
path: path.join(__dirname, 'dist/'),
filename: "[name].js"
},
devServer: {
hot: true,
inline: true,
proxy: {
"/api": {
target: "http://localhost:6767",
pathRewrite: {"^/api/v0" : "/api"},
}
}
},
target: "web",
cache: true,
watch: false,
module: {
rules: [
{
test: /\.jsx?$/,
loader: "babel-loader",
query: {
plugins: ['transform-decorators-legacy']
},
include: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "spec"),
path.resolve(__dirname, "node_modules/vm-leaflet-icons")
],
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
modules: 'global' // required because of [email protected]
}
}
]
},
{
test: /\.jpe?g$|\.gif$|\.png$/,
loader: "url-loader?limit=10000",
options: {
esModule: false,
},
},
{
test: /\.woff(2)?(\?v=\d+\.\d+\.\d+)?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url-loader?limit=10000&mimetype=application/octet-stream"
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file-loader"
},
{
test: /\.otf$/,
loader: 'url-loader?limit=10000&mimetype=application/font-otf'
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url-loader?limit=10000&mimetype=image/svg+xml",
options: {
esModule: false,
},
}
]
},
resolve: {
extensions: [".jsx", ".js"],
alias: {
// This is a quick fix:
// Without pointing to the minified leaflet file
// webpack includes 'leaflet-src.js'
leaflet$: path.resolve(__dirname, "node_modules/leaflet/dist/leaflet.js")
}
}
};
let htmlPluginOptions = {
template : "./src/index.html",
title : "Karte von morgen",
favicon : "./src/img/favicon.ico",
inject : 'body',
pack_for_nightly : (process.env.NODE_ENV === APP_STAGES.NIGHTLY)
};
switch (process.env.NODE_ENV) {
case APP_STAGES.LOCAL:
plugins.push(new webpack.DefinePlugin({
__DEVTOOLS__ : false,
__STAGE__ : JSON.stringify(APP_STAGES.LOCAL)
}));
plugins.push(new webpack.HotModuleReplacementPlugin());
break;
case APP_STAGES.NIGHTLY:
htmlPluginOptions.minify = {
removeComments : true,
collapseWhitespace : true,
conservativeCollapse : false,
minifyJS : true,
minifyCSS : true,
};
// Enable React optimizations.
plugins.push(new webpack.DefinePlugin({
'process.env.STAGE' : JSON.stringify('nightly'),
__DEVTOOLS__ : false,
__STAGE__ : JSON.stringify(APP_STAGES.NIGHTLY)
}));
break;
default:
// production
htmlPluginOptions.minify = {
removeComments : true,
collapseWhitespace : true,
conservativeCollapse : false,
minifyJS : true,
minifyCSS : true,
};
// Enable React optimizations.
plugins.push(new webpack.DefinePlugin({
'process.env.STAGE' : JSON.stringify('production'),
__DEVTOOLS__ : false,
__STAGE__ : JSON.stringify(APP_STAGES.PRODUCTION)
}));
}
plugins.push(new HTMLPlugin({
...htmlPluginOptions,
filename: "index.html",
chunks: ["app"]
}));
plugins.push(new HTMLPlugin({
...htmlPluginOptions,
filename: "businesscard.html",
chunks: ["businesscard_widget"]
}));
plugins.push(new HTMLPlugin({
...htmlPluginOptions,
filename: "map.html",
chunks: ["map_widget"]
}));
plugins.push(new HTMLPlugin({
...htmlPluginOptions,
filename: "mapAndEntryList.html",
chunks: ["mapAndEntryList_widget"]
}));
config.plugins = plugins;
module.exports = config;