-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
88 lines (84 loc) · 1.98 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
const path = require("path");
const webpack = require("webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin')
var webpackConfig = {
entry: [
"babel-polyfill",
"./src/demo.jsx",
"react-hot-loader/patch",
"webpack/hot/only-dev-server",
"webpack-dev-server/client?http://0.0.0.0:8487"
],
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
presets: ["react", "env", "stage-0"]
}
}, {
test: /\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.(ttf|svg|eot|woff)/,
loader: 'file-loader'
},
{
test: /\.s[a|c]ss$/,
loader: 'sass-loader!style-loader!css-loader'
},
{
test: /\.(jpg|png|gif|jpeg|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
}
]
},
resolve: {
extensions: [".css", ".js", ".jsx"],
//alias: {
// Fake jquery needed for slider
// "jquery": path.join(__dirname, "./src/jquery-stub.js")
// }
},
output: {
path: path.join(__dirname, "/build"),
publicPath: "/",
filename: "bundle.[hash].js"
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.EnvironmentPlugin({
'MINERVA_AUTHOR_ENV': 'local'
}),
new CopyWebpackPlugin([{
from: "static",
to: "."
}]),
new HtmlWebpackPlugin({
template: './static/index.html',
publicPath: '/',
})
],
devServer: {
contentBase: "./build",
hot: true,
proxy: {
"/dev/**": {
"target": "https://nldzj7hd69.execute-api.us-east-1.amazonaws.com",
"changeOrigin": true
}
}
}
};
module.exports = (env, argv) => {
if (argv.mode === 'production') {
console.log('Production mode');
delete webpackConfig.devServer;
webpackConfig.entry = ['./src/demo.jsx'];
}
return webpackConfig;
};