-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.dev.js
44 lines (41 loc) · 1.19 KB
/
webpack.config.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
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const path = require('path');
const { ProvidePlugin } = require('webpack');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const defaultWebpackConfig = require('./webpack.config');
/**
* Generate a webpack configuration for a canister.
*/
function generateWebpackDevConfig(config) {
if (config.entry.index.includes('linkedup')) { // don't run linkedup in dev mode
return;
}
const { outputRoot } = config
return {
...config,
mode: 'development',
devServer: {
contentBase: outputRoot,
compress: true,
port: 8900,
proxy: {
'/proxy': { target: 'http://localhost:8000/', pathRewrite: { '^/proxy': '' } },
'/': 'http://localhost:8000/',
}
},
devtool: 'source-map',
plugins: [
new BundleAnalyzerPlugin(),
new HTMLWebpackPlugin({ template: './index.html' }),
new ProvidePlugin({
ic: [path.resolve(path.join(__dirname, 'ic-polyfill.js')), 'ic'],
}),
],
};
}
// add on dev-mode-specific changes
module.exports = [
...defaultWebpackConfig
.map((config) => generateWebpackDevConfig(config))
.filter((x) => !!x),
];