-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
61 lines (57 loc) · 1.27 KB
/
webpack.dev.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
const path = require('path');
require('dotenv').config({ path: path.resolve(process.cwd(), '.env.development') });
require('dotenv').config();
const webpack = require('webpack');
const port = 8020;
const openBrowser = true;
const babel = true;
// inject envs
let plugins = [];
let envs = {};
Object.keys(process.env).filter(key => key.startsWith('MITHRIL_')).forEach(key => {
envs[key] = JSON.stringify(process.env[key]);
});
plugins.push(new webpack.DefinePlugin(envs));
let app = ['./client/index.js'];
let rules = [];
if (babel) {
// app.unshift('@babel/polyfill');
rules.push({
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-proposal-object-rest-spread'],
},
},
});
}
module.exports = {
entry: {
app: app,
},
output: {
filename: "static/app.js",
path: path.resolve(__dirname, 'build'),
publicPath: "/",
},
mode: 'development',
devtool: 'source-map',
devServer: {
port: port,
open: openBrowser,
historyApiFallback: {
index: 'index.html',
},
// proxy: {
// "/api": "http://localhost:3750"
// },
static: 'public',
},
plugins: plugins,
module: {
rules: rules,
},
};