-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwebpack.config.js
89 lines (81 loc) · 2.15 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
/*eslint-env node*/
var path = require("path");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var webpack = require("webpack");
var isProduction = process.env.NODE_ENV === "production";
var babelLoader = "babel?" + [
"presets[]=react",
"presets[]=es2015",
"presets[]=stage-0",
"plugins[]=transform-runtime"
].join(",");
module.exports = {
context: path.join(__dirname, "src"),
entry: ["./"],
devtool: !isProduction && "#source-map",
output: {
path: path.join(__dirname, "dist"),
publicPath: "/",
filename: process.env.NODE_ENV === "production"
? "bundle-[hash].js"
: "bundle.js"
},
resolve: {
root: path.join(__dirname, "src"),
alias: {
test: path.join(__dirname, "test")
}
},
plugins: [
new HtmlWebpackPlugin({
title: "Explore Apollo",
template: "index.html", // Load a custom template
inject: "body", //scripts are injected to here
favicon: "./favicon.ico"
}),
new webpack.ProvidePlugin({
fetch: "imports?this=>global!exports?global.fetch!whatwg-fetch"
}),
new webpack.DefinePlugin({
"process.env": {
COMMIT: JSON.stringify(
process.env.TRAVIS_COMMIT ||
process.env.GIT_COMMIT ||
"none"
),
TRAVIS_BUILD_ID: JSON.stringify(
process.env.TRAVIS_BUILD_ID ||
"N/A"
),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || "development"),
APP_ENV: JSON.stringify(process.env.APP_ENV || "development")
}
})
],
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: isProduction ? [
babelLoader
] : [
"react-hot",
babelLoader
]
},
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
},
{
test: /\.css$/,
loaders: ["style", "css"]
},
{ test: /\.(woff|woff2)$/, loader: "url-loader?limit=10000&mimetype=application/font-woff" },
{ test: /\.ttf$/, loader: "file-loader" },
{ test: /\.eot$/, loader: "file-loader" },
{ test: /\.svg$/, loader: "file-loader" }
]
}
};