-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev.js
80 lines (78 loc) · 1.89 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const path = require('path');
const common = require('./webpack.common');
const merge = require('webpack-merge');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
// DATAHUB
const DataHub = require('macaca-datahub');
const datahubMiddleware = require('datahub-proxy-middleware');
// DATAHUB CONFIG
const datahubConfig = {
port: 5678,
hostname: '0.0.0.0',
// eslint-disable-next-line no-undef
store: path.join(__dirname, 'data'),
pathOptions: {
start: true,
end: false
},
// eslint-disable-next-line no-undef
database: path.join(__dirname, '.macaca-datahub.sqlite'),
proxy: {
'/api': {
hub: 'api',
},
},
showBoard: true
};
const defaultDatahub = new DataHub({
port: datahubConfig.port,
});
module.exports = merge(common, {
mode: 'development',
output: {
filename: '[name].bundle.js',
// eslint-disable-next-line no-undef
path: path.resolve(__dirname, 'dist'),
chunkFilename: '[name].js'
},
plugins: [
new HtmlWebpackPlugin({
template: './app/index.html'
}),
new BundleAnalyzerPlugin()
],
devServer: {
host: '0.0.0.0',
port: 9090,
open: true,
overlay: true,
hot: true,
compress: true,
stats: 'minimal',
historyApiFallback: true,
before: app => {
datahubMiddleware(app)(datahubConfig);
},
after: () => {
defaultDatahub.startServer(datahubConfig).then(() => {
console.info('[datahub] => hub started...');
}).catch(() => {
console.warn('[datahub] => hub down...');
});
}
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.(scss|css)$/,
use: [
'style-loader', //3. Inject styles into DOM
'css-loader', //2. Turns css into commonjs
'sass-loader' //1. Turns sass into css
]
}
]
}
});