forked from alibaba/lowcode-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevConfig.ts
More file actions
55 lines (52 loc) · 1.31 KB
/
devConfig.ts
File metadata and controls
55 lines (52 loc) · 1.31 KB
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
import setAssetsPath from './setAssetsPath';
import WebpackChain from 'webpack-chain';
import * as path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import * as webpack from 'webpack';
import isWsl from 'is-wsl';
export default (config: WebpackChain, { pkg }) => {
setAssetsPath(config, { js: 'js', css: 'css' });
config.merge({
devServer: {
contentBase: path.join(__dirname, './public'),
logLevel: 'silent',
headers: {
'Access-Control-Allow-Origin': '*',
}
},
});
if (isWsl) {
config.merge({
devServer: {
watchOptions: {
poll: 1000,
}
}
})
}
config
.plugin('index')
.use(HtmlWebpackPlugin, [
{
inject: false,
templateParameters: {
},
template: path.join(__dirname, './public/index.html'),
filename: 'index.html',
},
]);
config
.plugin('preview')
.use(HtmlWebpackPlugin, [
{
inject: false,
templateParameters: {
},
template: path.join(__dirname, './public/preview.html'),
filename: 'preview.html',
},
]);
config.plugins.delete('hot');
config.devServer.hot(false).disableHostCheck(true);
config.plugin('define').use(webpack.DefinePlugin, [{ PACKAGE_NAME: JSON.stringify(pkg.name) }]);
};