-
Notifications
You must be signed in to change notification settings - Fork 13
/
webpack.config.js
94 lines (89 loc) · 2.38 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
const webpack = require("webpack")
const path = require("path")
const CopyWebpackPlugin = require("copy-webpack-plugin")
const UglifyJSPlugin = require("uglifyjs-webpack-plugin")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
favicon: path.resolve(__dirname, "src/favicon.ico"),
template: path.resolve(__dirname, "src/index.html"),
filename: "index.html",
inject: "body"
})
const webpackDefinePlugin = new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
"process.env.GOOGLE_API_KEY": JSON.stringify(
process.env.GOOGLE_API_KEY || null
)
})
const copyPlugin = new CopyWebpackPlugin([{from: "src/assets", to: "assets"}])
const optimizePlugins = [
new webpack.optimize.AggressiveMergingPlugin(),
new UglifyJSPlugin({
sourceMap: process.env.NODE_ENV !== "production"
})
]
module.exports = {
entry: {
app: ["babel-polyfill", "./src/index"]
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "index_bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
include: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "node_modules/@mapd/mapdc"),
path.resolve(__dirname, "node_modules/@mapd/crossfilter")
],
exclude: [
path.resolve(
__dirname,
"node_modules/@mapd/crossfilter/node_modules"
),
path.resolve(__dirname, "node_modules/@mapd/mapdc/node_modules"),
/(node_modules\/[^(@mapd)]+)/
]
},
{
test: /\.(scss|sass)$/,
use: [
{loader: "style-loader"},
{loader: "css-loader"},
{loader: "sass-loader"}
]
},
{
test: /\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.(png|otf|eot|svg|ttf|woff|woff2).*$/,
loader: "url-loader?limit=8192"
},
{
test: /\.svg$/,
loader: "file-loader"
},
{
test: /\.jpg$/,
loader: "file-loader"
},
{
test: /\.json$/,
loader: "json-loader"
}
]
},
devtool: process.env.NODE_ENV !== "production" ? "eval-source-map" : "none",
plugins: [
HtmlWebpackPluginConfig,
webpackDefinePlugin,
copyPlugin,
...optimizePlugins
]
}