-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
63 lines (58 loc) · 1.57 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
var path = require("path");
var HTMLWebpackPlugin = require("html-webpack-plugin");
const Dotenv = require('dotenv-webpack');
var SOURCE_DIR = path.resolve(__dirname, "src");
var TEMPLATE = path.resolve(SOURCE_DIR, "index.html");
var ENTRYPOINT = path.resolve(SOURCE_DIR, "js", "index.jsx");
var BUILD_DIR = path.resolve(__dirname, "build");
// Default mode to development
process.env["NODE_ENV"] = process.env["NODE_ENV"] || "development";
// HTML Injector plugin
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
template: TEMPLATE,
filename: "index.html",
inject: "head"
});
// ENV plugin
var ENVPlugin = new Dotenv()
module.exports = {
entry: ["@babel/polyfill", ENTRYPOINT],
mode: process.env["NODE_ENV"],
resolve: {
extensions: [".js", ".jsx", ".css", ".scss", ".sass"],
alias: {
"@src": SOURCE_DIR
}
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: [ "@babel/preset-env", "@babel/preset-react" ]
}
}
},
{
test: /\.(css|scss|sass)$/,
use:[ "style-loader","css-loader", "sass-loader" ]
}
]
},
output: {
filename: "bundle.js",
path: BUILD_DIR,
publicPath: "/"
},
plugins: [ HTMLWebpackPluginConfig, ENVPlugin ],
devtool: process.env["NODE_ENV"] === "development" ? "source-map" : false,
devServer: {
port: 8080,
historyApiFallback: true,
// Send API requests on localhost to API server to get around CORS.
proxy: {}
}
};